public void getContextAndInvoke(@NotNull final Project project,
                                  @NotNull final Editor editor,
                                  @Nullable final GrExpression expression,
                                  @Nullable final GrVariable variable,
                                  @Nullable final StringPartInfo stringPart) {
    final Scope[] scopes = findPossibleScopes(expression, variable, stringPart, editor);

    Consumer<? super Scope> callback = scope-> {
        GrIntroduceContext context = getContext(project, editor, expression, variable, stringPart, scope);
        invokeImpl(project, context, editor);
      };

    if (scopes.length == 0) {
      CommonRefactoringUtil.showErrorHint(
        project, editor,
        RefactoringBundle.getCannotRefactorMessage(getRefactoringName()),
        GroovyBundle.message("dialog.title.refactoring.unavailable.in.current.scope"),
        getHelpID()
      );
    }
    else if (scopes.length == 1) {
      callback.accept(scopes[0]);
    }
    else {
      showScopeChooser(scopes, callback, editor);
    }
  }
public void getContextAndInvoke(@NotNull final Project project,
                                  @NotNull final Editor editor,
                                  @Nullable final GrExpression expression,
                                  @Nullable final GrVariable variable,
                                  @Nullable final StringPartInfo stringPart)