void (@NotNull PsiElement element, @NotNull Project project, PsiElement nameSuggestionContext, Editor editor, String defaultName, RenamePsiElementProcessorBase processor) { PsiElement substituted = processor.substituteElementToRename(element, editor); if (substituted == null || !canRename(project, editor, substituted)) return; RenameRefactoringDialog dialog = processor.createDialog(project, substituted, nameSuggestionContext, editor); if (defaultName == null && ApplicationManager.getApplication().isUnitTestMode()) { String[] strings = dialog.getSuggestedNames(); if (strings != null && strings.length > 0) { Arrays.sort(strings); defaultName = strings[0]; } else { defaultName = "undefined"; // need to avoid show dialog in test } } if (defaultName != null) { try { dialog.performRename(defaultName); } finally { dialog.close(); // to avoid dialog leak } } else { dialog.show(); } }