void (PsiElement substitutedElement) { SmartPsiElementPointer<PsiMethod> pointer = SmartPointerManager.createPointer(method); MemberInplaceRenamer renamer = new MemberInplaceRenamer(method, substitutedElement, editor) { @Override protected boolean performRefactoring() { if (super.performRefactoring()) { ApplicationManager.getApplication().invokeLater(() -> { PsiMethod restored = pointer.getElement(); if (restored != null) { processMethodsDuplicates(restored); } }); return true; } return false; } }; final LinkedHashSet<String> nameSuggestions = new LinkedHashSet<>(suggestedNames); renamer.performInplaceRefactoring(nameSuggestions); }