@Override
  public void invoke(@NotNull Project project, PsiElement @NotNull [] elements, DataContext dataContext) {
    if (elements.length != 1 || !(elements[0] instanceof PsiMethod method)) return;
    try {
      new ConvertToInstanceMethodDialog(method, calculatePossibleInstanceQualifiers(method)).show();
    }
    catch (CommonRefactoringUtil.RefactoringErrorHintException e) {
      if (ApplicationManager.getApplication().isUnitTestMode()) throw e;
      Editor editor = CommonDataKeys.EDITOR.getData(dataContext);
      CommonRefactoringUtil.showErrorHint(project, editor, RefactoringBundle.getCannotRefactorMessage(e.getMessage()),
                                          getRefactoringName(), HelpID.CONVERT_TO_INSTANCE_METHOD);
    }
  }
@Override
  public void invoke(@NotNull Project project, PsiElement @NotNull [] elements, DataContext dataContext)