void (@NotNull final Project project, final Editor editor, final PsiFile file, @Nullable DataContext dataContext) { editor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE); final SelectionModel model = editor.getSelectionModel(); if (model.hasSelection()) { invokeImpl(project, editor, file, model.getSelectionStart(), model.getSelectionEnd()); } else { final List<GrExpression> expressions = GrIntroduceHandlerBase.collectExpressions(file, editor, editor.getCaretModel().getOffset(), true); final Consumer<GrExpression> callback = new Callback(project, editor, file); if (expressions.size() == 1) { callback.accept(expressions.get(0)); } else if (expressions.isEmpty()) { model.selectLineAtCaret(); invokeImpl(project, editor, file, model.getSelectionStart(), model.getSelectionEnd()); } else { IntroduceTargetChooser.showChooser(editor, expressions, Pass.create(callback), GrIntroduceHandlerBase.GR_EXPRESSION_RENDERER); } } }