use of com.intellij.execution.console.ConsoleExecuteAction in project intellij-community by JetBrains.
the class XEvaluateInConsoleFromEditorActionHandler method perform.
@Override
protected void perform(@NotNull XDebugSession session, DataContext dataContext) {
Editor editor = CommonDataKeys.EDITOR.getData(dataContext);
if (editor == null || !(editor instanceof EditorEx)) {
return;
}
int selectionStart = editor.getSelectionModel().getSelectionStart();
int selectionEnd = editor.getSelectionModel().getSelectionEnd();
Promise<Pair<TextRange, String>> rangeAndText = null;
if (selectionStart != selectionEnd) {
TextRange textRange = new TextRange(selectionStart, selectionEnd);
rangeAndText = Promise.resolve(Pair.create(textRange, editor.getDocument().getText(textRange)));
} else {
XDebuggerEvaluator evaluator = session.getDebugProcess().getEvaluator();
if (evaluator != null) {
Promise<ExpressionInfo> expressionInfoPromise = evaluator.getExpressionInfoAtOffsetAsync(session.getProject(), editor.getDocument(), selectionStart, true);
rangeAndText = expressionInfoPromise.then(expressionInfo -> {
if (expressionInfo == null) {
return null;
}
return Pair.create(expressionInfo.getTextRange(), XDebuggerEvaluateActionHandler.getExpressionText(expressionInfo, editor.getDocument()));
});
} else {
return;
}
}
rangeAndText.done(textRangeStringPair -> {
ApplicationManager.getApplication().invokeLater(() -> {
TextRange range = textRangeStringPair.getFirst();
String text = textRangeStringPair.getSecond();
if (text == null)
return;
ConsoleExecuteAction action = getConsoleExecuteAction(session);
if (action != null) {
action.execute(range, text, (EditorEx) editor);
}
});
});
}
use of com.intellij.execution.console.ConsoleExecuteAction in project intellij-community by JetBrains.
the class XEvaluateInConsoleFromEditorActionHandler method getConsoleExecuteAction.
@Nullable
public static ConsoleExecuteAction getConsoleExecuteAction(@Nullable ConsoleView consoleView) {
if (!(consoleView instanceof LanguageConsoleView)) {
return null;
}
List<AnAction> actions = ActionUtil.getActions(((LanguageConsoleView) consoleView).getConsoleEditor().getComponent());
ConsoleExecuteAction action = ContainerUtil.findInstance(actions, ConsoleExecuteAction.class);
return action == null || !action.isEnabled() ? null : action;
}
use of com.intellij.execution.console.ConsoleExecuteAction in project intellij-community by JetBrains.
the class PydevConsoleRunnerImpl method fillToolBarActions.
private List<AnAction> fillToolBarActions(final DefaultActionGroup toolbarActions, final RunContentDescriptor contentDescriptor) {
//toolbarActions.add(backspaceHandlingAction);
toolbarActions.add(createRerunAction());
List<AnAction> actions = ContainerUtil.newArrayList();
//stop
actions.add(createStopAction());
//close
actions.add(createCloseAction(contentDescriptor));
// run action
actions.add(new ConsoleExecuteAction(myConsoleView, myConsoleExecuteActionHandler, myConsoleExecuteActionHandler.getEmptyExecuteAction(), myConsoleExecuteActionHandler));
// Help
actions.add(CommonActionsManager.getInstance().createHelpAction("interactive_console"));
toolbarActions.addAll(actions);
actions.add(0, createRerunAction());
actions.add(createInterruptAction());
actions.add(PyConsoleUtil.createTabCompletionAction(myConsoleView));
actions.add(createSplitLineAction());
toolbarActions.add(new ShowVarsAction(myConsoleView, myPydevConsoleCommunication));
toolbarActions.add(ConsoleHistoryController.getController(myConsoleView).getBrowseHistory());
toolbarActions.add(new ConnectDebuggerAction());
toolbarActions.add(new NewConsoleAction());
return actions;
}
Aggregations