boolean (@NotNull Editor editor, @NotNull PsiFile file, @NotNull DataContext dataContext) { List<PsiElement> elements = CommonRefactoringUtil.findElementsFromCaretsAndSelections(editor, file, PsiCodeBlock.class, e -> e instanceof PsiMember); if (elements.isEmpty()) return false; PsiClass psiClass = PsiTreeUtil.getParentOfType(elements.get(0), PsiClass.class, false); if (psiClass == null) return false; return psiClass instanceof PsiAnonymousClass || RefactoringActionContextUtil.isClassWithExtendsOrImplements(psiClass); }