@Override
  public void invoke(@NotNull Project project, PsiElement @NotNull [] elements, DataContext dataContext) {
    PsiElement parent = PsiTreeUtil.findCommonParent(elements);
    final PsiClass containingClass = parent instanceof PsiClass aClass
                                     ? aClass
                                     : PsiTreeUtil.getParentOfType(parent, PsiClass.class, false);
    final String cannotRefactorMessage = getCannotRefactorMessage(containingClass);
    if (cannotRefactorMessage != null)  {
      CommonRefactoringUtil.showErrorHint(project, null,
                                          RefactorJBundle.message("cannot.perform.the.refactoring") + cannotRefactorMessage,
                                          getRefactoringName(), HelpID.ExtractClass);
      return;
    }
    if (!CommonRefactoringUtil.checkReadOnlyStatus(project, containingClass)) return;

    final Set<PsiElement> selectedMembers = new HashSet<>();
    Collections.addAll(selectedMembers, elements);
    new ExtractClassDialog(containingClass, selectedMembers).show();
  }
@Override
  public void invoke(@NotNull Project project, PsiElement @NotNull [] elements, DataContext dataContext)