void (@NotNull PsiMethod method, @NotNull final PsiElementProcessor<? super PsiMethod> processor, @NotNull Editor editor) { ThreadingAssertions.assertEventDispatchThread(); PsiClass aClass = method.getContainingClass(); if (aClass == null) { processor.execute(method); return; } PsiMethod[] superMethods = method.findDeepestSuperMethods(); if (superMethods.length == 0) { processor.execute(method); return; } final PsiClass containingClass = superMethods[0].getContainingClass(); if (containingClass == null) { processor.execute(method); return; } if (ApplicationManager.getApplication().isUnitTestMode()) { processor.execute(superMethods[0]); return; } final PsiMethod[] methods = {superMethods[0], method}; final String renameBase = JavaRefactoringBundle.message("refactor.base.method.choice", superMethods.length > 1 ? 0 : 1); final String renameCurrent = JavaRefactoringBundle.message("refactor.only.current.method.choice"); String title; if (superMethods.length > 1) { title = JavaBundle.message("rename.super.methods.chooser.popup.title", method.getName()); } else { title = JavaBundle.message("rename.super.base.chooser.popup.title", method.getName(), containingClass.isInterface() && !aClass.isInterface() ? 0 : 1, SymbolPresentationUtil.getSymbolPresentableText(containingClass)); } JBPopupFactory.getInstance().createPopupChooserBuilder(List.of(renameBase, renameCurrent)) .setTitle(title) .setMovable(false) .setResizable(false) .setRequestFocus(true) .setItemChosenCallback(value -> { if (value.equals(renameBase)) { try { methods[0].putUserData(SIBLINGS, superMethods); processor.execute(methods[0]); } finally { methods[0].putUserData(SIBLINGS, null); } } else { processor.execute(methods[1]); } }) .createPopup().showInBestPositionFor(editor); }