Search in sources :

Example 16 with XDebugSession

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);
            }
        });
    });
}
Also used : DataContext(com.intellij.openapi.actionSystem.DataContext) ActionUtil(com.intellij.openapi.actionSystem.ex.ActionUtil) AnAction(com.intellij.openapi.actionSystem.AnAction) TextRange(com.intellij.openapi.util.TextRange) ContainerUtil(com.intellij.util.containers.ContainerUtil) Editor(com.intellij.openapi.editor.Editor) ExpressionInfo(com.intellij.xdebugger.evaluation.ExpressionInfo) Nullable(org.jetbrains.annotations.Nullable) Promise(org.jetbrains.concurrency.Promise) List(java.util.List) ConsoleView(com.intellij.execution.ui.ConsoleView) Pair(com.intellij.openapi.util.Pair) ApplicationManager(com.intellij.openapi.application.ApplicationManager) EditorEx(com.intellij.openapi.editor.ex.EditorEx) CommonDataKeys(com.intellij.openapi.actionSystem.CommonDataKeys) ConsoleExecuteAction(com.intellij.execution.console.ConsoleExecuteAction) LanguageConsoleView(com.intellij.execution.console.LanguageConsoleView) NotNull(org.jetbrains.annotations.NotNull) XDebugSession(com.intellij.xdebugger.XDebugSession) XDebuggerEvaluator(com.intellij.xdebugger.evaluation.XDebuggerEvaluator) EditorEx(com.intellij.openapi.editor.ex.EditorEx) XDebuggerEvaluator(com.intellij.xdebugger.evaluation.XDebuggerEvaluator) TextRange(com.intellij.openapi.util.TextRange) Editor(com.intellij.openapi.editor.Editor) ExpressionInfo(com.intellij.xdebugger.evaluation.ExpressionInfo) ConsoleExecuteAction(com.intellij.execution.console.ConsoleExecuteAction) Pair(com.intellij.openapi.util.Pair)

Example 17 with XDebugSession

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();
}
Also used : XDebugSession(com.intellij.xdebugger.XDebugSession) XDebuggerTreeState(com.intellij.xdebugger.impl.ui.tree.XDebuggerTreeState) ValueMarkerPresentationDialog(com.intellij.xdebugger.impl.ui.tree.ValueMarkerPresentationDialog) XValueNodeImpl(com.intellij.xdebugger.impl.ui.tree.nodes.XValueNodeImpl) XValue(com.intellij.xdebugger.frame.XValue) ValueMarkup(com.intellij.xdebugger.impl.ui.tree.ValueMarkup) XDebugSessionImpl(com.intellij.xdebugger.impl.XDebugSessionImpl)

Example 18 with XDebugSession

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);
    }
}
Also used : XDebugSession(com.intellij.xdebugger.XDebugSession)

Example 19 with XDebugSession

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;
}
Also used : KeyEvent(java.awt.event.KeyEvent) Project(com.intellij.openapi.project.Project) XDebugSession(com.intellij.xdebugger.XDebugSession)

Example 20 with XDebugSession

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);
    }
}
Also used : XDebugSession(com.intellij.xdebugger.XDebugSession) Presentation(com.intellij.openapi.actionSystem.Presentation)

Aggregations

XDebugSession (com.intellij.xdebugger.XDebugSession)50 Project (com.intellij.openapi.project.Project)15 NotNull (org.jetbrains.annotations.NotNull)13 XDebugProcessStarter (com.intellij.xdebugger.XDebugProcessStarter)9 XDebugSessionImpl (com.intellij.xdebugger.impl.XDebugSessionImpl)9 XDebugProcess (com.intellij.xdebugger.XDebugProcess)8 Nullable (org.jetbrains.annotations.Nullable)7 DebuggerSession (com.intellij.debugger.impl.DebuggerSession)6 IOException (java.io.IOException)5 DebugProcessImpl (com.intellij.debugger.engine.DebugProcessImpl)4 ExecutionException (com.intellij.execution.ExecutionException)4 XValueNodeImpl (com.intellij.xdebugger.impl.ui.tree.nodes.XValueNodeImpl)4 DebugEnvironment (com.intellij.debugger.DebugEnvironment)3 VirtualMachineProxyImpl (com.intellij.debugger.jdi.VirtualMachineProxyImpl)3 ExecutionResult (com.intellij.execution.ExecutionResult)3 RunContentDescriptor (com.intellij.execution.ui.RunContentDescriptor)3 XSourcePosition (com.intellij.xdebugger.XSourcePosition)3 ServerSocket (java.net.ServerSocket)3 List (java.util.List)3 DefaultDebugEnvironment (com.intellij.debugger.DefaultDebugEnvironment)2