void (@NotNull Project project, Editor editor, PsiFile file, DataContext dataContext) { editor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE); List<PsiMember> elements = CommonRefactoringUtil.findElementsFromCaretsAndSelections(editor, file, null, e -> e instanceof PsiMember); PsiElement parent = PsiTreeUtil.findCommonParent(elements); PsiClass containingClass = parent instanceof PsiClass parentClass ? parentClass : PsiTreeUtil.getParentOfType(parent, PsiClass.class, false); final String cannotRefactorMessage = getCannotRefactorMessage(containingClass); if (cannotRefactorMessage != null) { CommonRefactoringUtil.showErrorHint(project, editor, RefactorJBundle.message("cannot.perform.the.refactoring") + cannotRefactorMessage, getRefactoringName(), HelpID.ExtractClass); return; } new ExtractClassDialog(containingClass, new HashSet<>(elements)).show(); }