void (@NotNull Project project, PsiElement @NotNull [] elements, DataContext dataContext) { PsiElement parent = PsiTreeUtil.findCommonParent(elements); myClass = parent instanceof PsiClass aClass ? aClass : PsiTreeUtil.getParentOfType(parent, PsiClass.class, false); if (myClass == null) { String message = RefactoringBundle.message("error.select.class.to.be.refactored"); CommonRefactoringUtil.showErrorHint(project, null, message, getRefactoringName(), HelpID.EXTRACT_INTERFACE); return; } if (myClass instanceof PsiUnnamedClass) { String message = RefactoringBundle.message("error.interface.cannot.be.extracted.from.unnamed.class"); CommonRefactoringUtil.showErrorHint(project, null, message, getRefactoringName(), HelpID.EXTRACT_INTERFACE); return; } if (!CommonRefactoringUtil.checkReadOnlyStatus(project, myClass)) return; final Set<PsiElement> selectedMembers = new HashSet<>(); Collections.addAll(selectedMembers, elements); final ExtractInterfaceDialog dialog = new ExtractInterfaceDialog(project, myClass, selectedMembers); if (!dialog.showAndGet() || !dialog.isExtractSuperclass()) { return; } final MultiMap<PsiElement, String> conflicts = new MultiMap<>(); ExtractSuperClassUtil.checkSuperAccessible(dialog.getTargetDirectory(), conflicts, myClass); if (!ExtractSuperClassUtil.showConflicts(dialog, conflicts, project)) return; PsiClass anInterface = WriteCommandAction .writeCommandAction(project) .withName(getRefactoringName()) .compute(() -> { myInterfaceName = dialog.getExtractedSuperName(); mySelectedMembers = dialog.getSelectedMemberInfos().toArray(new MemberInfo[0]); myTargetDir = dialog.getTargetDirectory(); myJavaDocPolicy = new DocCommentPolicy(dialog.getDocCommentPolicy()); LocalHistoryAction a = LocalHistory.getInstance().startAction(getCommandName()); try { return extractInterface(myTargetDir, myClass, myInterfaceName, mySelectedMembers, myJavaDocPolicy); } finally { a.finish(); } }); ExtractClassUtil.askAndTurnRefsToSuper(myClass, anInterface); }