void () { final PsiElement anonymousClassStatement = ptr.getElement(); if (anonymousClassStatement == null) { return; } final Ref<PsiClass> newClassRef = new Ref<>(); anonymousClassStatement.accept(new JavaRecursiveElementWalkingVisitor() { @Override public void visitClass(@NotNull PsiClass aClass) { newClassRef.set(aClass); } }); final PsiClass newClass = newClassRef.get(); final Editor editor = getEditor(); if (editor != null && newClass != null) { PsiElement brace = newClass.getLBrace(); if (brace != null) { editor.getCaretModel().moveToOffset(brace.getTextOffset()); } CommandProcessor.getInstance().executeCommand(myClass.getProject(), () -> { if (!OverrideImplementExploreUtil.getMethodSignaturesToImplement(newClass).isEmpty()) { OverrideImplementUtil.chooseAndImplementMethods(newClass.getProject(), editor, newClass); } else { OverrideImplementUtil.chooseAndOverrideMethods(newClass.getProject(), editor, newClass); } }, "", null); } }