use of com.intellij.xdebugger.XDebugSession 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.xdebugger.XDebugSession in project intellij-community by JetBrains.
the class XMarkObjectActionHandler method perform.
@Override
public void perform(@NotNull Project project, AnActionEvent event) {
XDebugSession session = XDebuggerManager.getInstance(project).getCurrentSession();
if (session == null)
return;
XValueMarkers<?, ?> markers = ((XDebugSessionImpl) session).getValueMarkers();
XValueNodeImpl node = XDebuggerTreeActionBase.getSelectedNode(event.getDataContext());
if (markers == null || node == null)
return;
XValue value = node.getValueContainer();
boolean detachedView = DebuggerUIUtil.isInDetachedTree(event);
XDebuggerTreeState treeState = XDebuggerTreeState.saveState(node.getTree());
ValueMarkup existing = markers.getMarkup(value);
if (existing != null) {
markers.unmarkValue(value);
} else {
ValueMarkerPresentationDialog dialog = new ValueMarkerPresentationDialog(event.getData(CONTEXT_COMPONENT), node.getName());
dialog.show();
ValueMarkup markup = dialog.getConfiguredMarkup();
if (dialog.isOK() && markup != null) {
markers.markValue(value, markup);
}
}
if (detachedView) {
node.getTree().rebuildAndRestore(treeState);
}
session.rebuildViews();
}
use of com.intellij.xdebugger.XDebugSession in project intellij-community by JetBrains.
the class XWatchesViewImpl method addWatchExpression.
@Override
public void addWatchExpression(@NotNull XExpression expression, int index, final boolean navigateToWatchNode) {
XDebugSession session = getSession(getTree());
myRootNode.addWatchExpression(session != null ? session.getCurrentStackFrame() : null, expression, index, navigateToWatchNode);
updateSessionData();
if (navigateToWatchNode && session != null) {
XDebugSessionTab.showWatchesView((XDebugSessionImpl) session);
}
}
use of com.intellij.xdebugger.XDebugSession in project intellij-community by JetBrains.
the class ResumeAction method isEnabled.
@Override
protected boolean isEnabled(AnActionEvent e) {
Project project = e.getProject();
if (project == null)
return false;
XDebugSession session = XDebuggerManager.getInstance(project).getCurrentSession();
if (session != null && !session.isStopped()) {
return session.isPaused();
}
// disable visual representation but leave the shortcut action enabled
return e.getInputEvent() instanceof KeyEvent;
}
use of com.intellij.xdebugger.XDebugSession in project intellij-community by JetBrains.
the class ShowLibraryFramesAction method update.
@Override
public void update(@NotNull final AnActionEvent e) {
super.update(e);
Presentation presentation = e.getPresentation();
Object isSupported = presentation.getClientProperty(IS_LIBRARY_FRAME_FILTER_SUPPORTED);
XDebugSession session = e.getData(XDebugSession.DATA_KEY);
if (isSupported == null) {
if (session == null) {
// if session is null and isSupported is null - just return, it means that action created initially not in the xdebugger tab
presentation.setVisible(false);
return;
}
isSupported = session.getDebugProcess().isLibraryFrameFilterSupported();
presentation.putClientProperty(IS_LIBRARY_FRAME_FILTER_SUPPORTED, isSupported);
}
if (Boolean.TRUE.equals(isSupported)) {
presentation.setVisible(true);
final boolean shouldShow = !Boolean.TRUE.equals(presentation.getClientProperty(SELECTED_PROPERTY));
presentation.setText(shouldShow ? ourTextWhenShowIsOn : ourTextWhenShowIsOff);
} else {
presentation.setVisible(false);
}
}
Aggregations