@Override
  public void invoke(@NotNull Project project, Editor editor, PsiFile file, DataContext dataContext) {
    if (editor == null || file == null) {
      return;
    }

    if (!CommonRefactoringUtil.checkReadOnlyStatus(project, file)) {
      return;
    }

    PsiDocumentManager.getInstance(project).commitAllDocuments();

    int caretCount = editor.getCaretModel().getCaretCount();
    if (caretCount != 1) {
      cannotPerformRefactoring(project, editor);
      return;
    }

    SelectionModel selectionModel = editor.getSelectionModel();

    if (selectionModel.hasSelection()) {
      invokeOnSelection(selectionModel.getSelectionStart(), selectionModel.getSelectionEnd(), project, editor, file);
    }
    else {
      Pair<List<Target>, Integer> targetInfo = collectTargets(file, editor, project);
      List<Target> list = targetInfo.getFirst();
      if (list.isEmpty()) {
        cannotPerformRefactoring(project, editor);
      }
      else if (list.size() == 1) {
        invokeOnTarget(list.get(0), file, editor, project);
      }
      else {
        IntroduceTargetChooser.showIntroduceTargetChooser(editor, list, target -> invokeOnTarget(target, file, editor, project), RefactoringBundle.message("introduce.target.chooser.expressions.title"), targetInfo.getSecond());
      }
    }
  }
@Override
  public void invoke(@NotNull Project project, Editor editor, PsiFile file, DataContext dataContext)