boolean (@NotNull Project project, Editor editor, PsiFile file) { final int position = editor.getCaretModel().getOffset(); PsiElement element = file.findElementAt(position); PsiClass psiClass = PsiTreeUtil.getParentOfType(element, PsiClass.class); if (psiClass == null || psiClass.isAnnotationType() || psiClass.isEnum() || psiClass instanceof PsiAnonymousClass || psiClass.hasModifierProperty(PsiModifier.FINAL)) { return false; } VirtualFile virtualFile = PsiUtilCore.getVirtualFile(psiClass); if (virtualFile == null) { return false; } if (!isSupportedLanguage(psiClass)) return false; final PsiMethod[] constructors = psiClass.getConstructors(); if (constructors.length > 0) { boolean hasNonPrivateConstructor = false; for (PsiMethod constructor : constructors) { if (!constructor.hasModifierProperty(PsiModifier.PRIVATE)) { hasNonPrivateConstructor = true; break; } } if (!hasNonPrivateConstructor) return false; } PsiElement lBrace = psiClass.getLBrace(); if (lBrace == null) return false; if (element.getTextOffset() >= lBrace.getTextOffset()) return false; TextRange declarationRange = HighlightNamesUtil.getClassDeclarationTextRange(psiClass); final TextRange elementTextRange = element.getTextRange(); if (!declarationRange.contains(elementTextRange)) { if (!(element instanceof PsiWhiteSpace) || (declarationRange.getStartOffset() != elementTextRange.getEndOffset() && declarationRange.getEndOffset() != elementTextRange.getStartOffset())) { return false; } } if (shouldCreateInnerClass(psiClass) && !canModify(file)) { return false; } myText = decapitalize(getTitle(psiClass)); return true; }