boolean (@NotNull final Project project, final Editor editor, final PsiFile file) { final PsiJavaCodeReferenceElement element = getRefElement(); if (element == null || (!element.getManager().isInProject(element) && !ScratchUtil.isScratch(PsiUtilCore.getVirtualFile(element)))) { return false; } JavaResolveResult[] results = element.multiResolve(true); if (results.length > 0 && results[0].getElement() instanceof PsiClass) { return false; } final String refName = element.getReferenceName(); if (refName == null || PsiTreeUtil.getParentOfType(element, PsiTypeElement.class, PsiReferenceList.class) == null && !checkClassName(refName)) return false; PsiElement nameElement = element.getReferenceNameElement(); if (nameElement == null) return false; PsiElement parent = element.getParent(); if (parent instanceof PsiExpression && !(parent instanceof PsiReferenceExpression)) return false; if (!isAvailableInContext(element)) return false; final String superClassName = getSuperClassName(element); if (superClassName != null) { if (superClassName.equals(CommonClassNames.JAVA_LANG_ENUM) && myKind != CreateClassKind.ENUM) return false; if (superClassName.equals(CommonClassNames.JAVA_LANG_RECORD) && myKind != CreateClassKind.RECORD) return false; final PsiClass psiClass = JavaPsiFacade.getInstance(project).findClass(superClassName, GlobalSearchScope.allScope(project)); if (psiClass != null && psiClass.hasModifierProperty(PsiModifier.FINAL)) return false; } final int offset = editor.getCaretModel().getOffset(); if (CreateFromUsageUtils.shouldShowTag(offset, nameElement, element)) { setText(getText(nameElement.getText())); return true; } return false; }