@Nullable
  public static @Nls String getCannotInlineMessage(final PsiClass psiClass) {
    if (psiClass instanceof PsiTypeParameter) {
      return JavaBundle.message("type.parameters.cannot.be.inlined");
    }
    if (psiClass.isAnnotationType()) {
      return JavaBundle.message("annotation.types.cannot.be.inlined");
    }
    if (psiClass.isInterface()) {
      return JavaBundle.message("interfaces.cannot.be.inlined");
    }
    if (psiClass.isEnum()) {
      return JavaBundle.message("enums.cannot.be.inlined");
    }
    if (psiClass.hasModifierProperty(PsiModifier.ABSTRACT)) {
      return JavaRefactoringBundle.message("inline.to.anonymous.no.abstract");
    }
    if (psiClass instanceof PsiCompiledElement) {
      return JavaBundle.message("library.classes.cannot.be.inlined");
    }

    PsiClassType[] classTypes = psiClass.getExtendsListTypes();
    for(PsiClassType classType: classTypes) {
      PsiClass superClass = classType.resolve();
      if (superClass == null) {
        return JavaBundle.message("class.cannot.be.inlined.because.its.superclass.cannot.be.resolved");
      }
    }

    final PsiClassType[] interfaces = psiClass.getImplementsListTypes();
    if (interfaces.length > 1) {
      return JavaRefactoringBundle.message("inline.to.anonymous.no.multiple.interfaces");
    }
    if (interfaces.length == 1) {
      if (interfaces [0].resolve() == null) {
        return JavaBundle.message("class.cannot.be.inlined.because.an.interface.implemented.by.it.cannot.be.resolved");
      }
      final PsiClass superClass = psiClass.getSuperClass();
      if (superClass != null && !CommonClassNames.JAVA_LANG_OBJECT.equals(superClass.getQualifiedName())) {
        PsiClassType interfaceType = interfaces[0];
        if (!isRedundantImplements(superClass, interfaceType)) {
          return JavaRefactoringBundle.message("inline.to.anonymous.no.superclass.and.interface");
        }
      }
    }

    final GlobalSearchScope searchScope = GlobalSearchScope.projectScope(psiClass.getProject());
    final PsiMethod[] methods = psiClass.getMethods();
    for(PsiMethod method: methods) {
      if (method.isConstructor()) {
        if (PsiUtil.findReturnStatements(method).length > 0) {
          return JavaBundle.message("class.cannot.be.inlined.because.its.constructor.contains.return.statements");
        }
      }
      else if (method.findSuperMethods().length == 0) {
        if (!ReferencesSearch.search(method, searchScope).forEach(new AllowedUsagesProcessor(psiClass))) {
          return JavaBundle
            .message("class.cannot.be.inlined.because.there.are.usages.of.its.methods.not.inherited.from.its.superclass.or.interface");
        }
      }
      if (method.hasModifierProperty(PsiModifier.STATIC)) {
        return JavaBundle.message("class.cannot.be.inlined.because.it.has.static.methods");
      }
    }

    final PsiClass[] innerClasses = psiClass.getInnerClasses();
    for(PsiClass innerClass: innerClasses) {
      PsiModifierList classModifiers = innerClass.getModifierList();
      if (classModifiers != null && classModifiers.hasModifierProperty(PsiModifier.STATIC)) {
        return JavaBundle.message("class.cannot.be.inlined.because.it.has.static.inner.classes");
      }
      if (!ReferencesSearch.search(innerClass, searchScope).forEach(new AllowedUsagesProcessor(psiClass))) {
        return JavaBundle.message("class.cannot.be.inlined.because.it.has.usages.of.its.inner.classes");
      }
    }

    final PsiField[] fields = psiClass.getFields();
    for(PsiField field: fields) {
      final PsiModifierList fieldModifiers = field.getModifierList();
      if (fieldModifiers != null && fieldModifiers.hasModifierProperty(PsiModifier.STATIC)) {
        if (!fieldModifiers.hasModifierProperty(PsiModifier.FINAL)) {
          return JavaBundle.message("class.cannot.be.inlined.because.it.has.static.non.final.fields");
        }
        Object initValue = null;
        final PsiExpression initializer = field.getInitializer();
        if (initializer != null) {
          initValue = JavaPsiFacade.getInstance(psiClass.getProject()).getConstantEvaluationHelper().computeConstantExpression(initializer);
        }
        if (initValue == null) {
          return JavaBundle.message("class.cannot.be.inlined.because.it.has.static.fields.with.non.constant.initializers");
        }
      }
      if (!ReferencesSearch.search(field, searchScope).forEach(new AllowedUsagesProcessor(psiClass))) {
        return JavaBundle.message("class.cannot.be.inlined.because.it.has.usages.of.fields.not.inherited.from.its.superclass");
      }
    }

    final PsiClassInitializer[] initializers = psiClass.getInitializers();
    for(PsiClassInitializer initializer: initializers) {
      final PsiModifierList modifiers = initializer.getModifierList();
      if (modifiers != null && modifiers.hasModifierProperty(PsiModifier.STATIC)) {
        return JavaBundle.message("class.cannot.be.inlined.because.it.has.static.initializers");
      }
    }

    return getCannotInlineDueToUsagesMessage(psiClass);
  }
@Nullable
  public static @Nls String getCannotInlineMessage(final PsiClass psiClass)