void (@NotNull final GrReferenceExpression ref, @NotNull final Editor editor, final Project project) { PsiElement place = ref; final List<GrMethod> scopes = new ArrayList<>(); while (true) { final GrMethod parent = PsiTreeUtil.getParentOfType(place, GrMethod.class); if (parent == null) break; scopes.add(parent); place = parent; } if (scopes.size() == 1) { final GrMethod owner = scopes.get(0); final PsiMethod toSearchFor = SuperMethodWarningUtil.checkSuperMethod(owner); if (toSearchFor == null) return; //if it is null, refactoring was canceled showDialog(toSearchFor, ref, project); } else if (scopes.size() > 1) { myEnclosingMethodsPopup = MethodOrClosureScopeChooser.create(scopes, editor, this, (owner, element) -> { if (owner != null) { showDialog((PsiMethod)owner, ref, project); } return null; }); myEnclosingMethodsPopup.showInBestPositionFor(editor); } }