Search in sources :

Example 1 with ThreadDescriptorImpl

use of com.intellij.debugger.ui.impl.watch.ThreadDescriptorImpl in project intellij-community by JetBrains.

the class InterruptThreadAction method update.

public void update(AnActionEvent e) {
    final DebuggerTreeNodeImpl[] selectedNodes = getSelectedNodes(e.getDataContext());
    boolean visible = false;
    boolean enabled = false;
    if (selectedNodes != null && selectedNodes.length > 0) {
        visible = true;
        enabled = true;
        for (DebuggerTreeNodeImpl selectedNode : selectedNodes) {
            final NodeDescriptorImpl threadDescriptor = selectedNode.getDescriptor();
            if (!(threadDescriptor instanceof ThreadDescriptorImpl)) {
                visible = false;
                break;
            }
        }
        if (visible) {
            for (DebuggerTreeNodeImpl selectedNode : selectedNodes) {
                final ThreadDescriptorImpl threadDescriptor = (ThreadDescriptorImpl) selectedNode.getDescriptor();
                if (threadDescriptor.isFrozen() || threadDescriptor.isSuspended()) {
                    enabled = false;
                    break;
                }
            }
        }
    }
    final Presentation presentation = e.getPresentation();
    presentation.setText(DebuggerBundle.message("action.interrupt.thread.text"));
    presentation.setEnabledAndVisible(visible && enabled);
}
Also used : DebuggerTreeNodeImpl(com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl) ThreadDescriptorImpl(com.intellij.debugger.ui.impl.watch.ThreadDescriptorImpl) Presentation(com.intellij.openapi.actionSystem.Presentation) NodeDescriptorImpl(com.intellij.debugger.ui.impl.watch.NodeDescriptorImpl)

Example 2 with ThreadDescriptorImpl

use of com.intellij.debugger.ui.impl.watch.ThreadDescriptorImpl in project intellij-community by JetBrains.

the class FreezeThreadAction method update.

public void update(AnActionEvent e) {
    DebuggerTreeNodeImpl[] selectedNode = getSelectedNodes(e.getDataContext());
    if (selectedNode == null) {
        return;
    }
    DebugProcessImpl debugProcess = getDebuggerContext(e.getDataContext()).getDebugProcess();
    boolean visible = false;
    if (debugProcess != null) {
        visible = true;
        for (DebuggerTreeNodeImpl aSelectedNode : selectedNode) {
            NodeDescriptorImpl threadDescriptor = aSelectedNode.getDescriptor();
            if (!(threadDescriptor instanceof ThreadDescriptorImpl) || ((ThreadDescriptorImpl) threadDescriptor).isSuspended()) {
                visible = false;
                break;
            }
        }
    }
    e.getPresentation().setVisible(visible);
}
Also used : DebuggerTreeNodeImpl(com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl) DebugProcessImpl(com.intellij.debugger.engine.DebugProcessImpl) ThreadDescriptorImpl(com.intellij.debugger.ui.impl.watch.ThreadDescriptorImpl) NodeDescriptorImpl(com.intellij.debugger.ui.impl.watch.NodeDescriptorImpl)

Example 3 with ThreadDescriptorImpl

use of com.intellij.debugger.ui.impl.watch.ThreadDescriptorImpl in project intellij-community by JetBrains.

the class FreezeThreadAction method actionPerformed.

public void actionPerformed(final AnActionEvent e) {
    DebuggerTreeNodeImpl[] selectedNode = getSelectedNodes(e.getDataContext());
    if (selectedNode == null) {
        return;
    }
    final DebuggerContextImpl debuggerContext = getDebuggerContext(e.getDataContext());
    final DebugProcessImpl debugProcess = debuggerContext.getDebugProcess();
    for (final DebuggerTreeNodeImpl debuggerTreeNode : selectedNode) {
        ThreadDescriptorImpl threadDescriptor = ((ThreadDescriptorImpl) debuggerTreeNode.getDescriptor());
        final ThreadReferenceProxyImpl thread = threadDescriptor.getThreadReference();
        if (!threadDescriptor.isFrozen()) {
            debugProcess.getManagerThread().schedule(new DebuggerCommandImpl() {

                @Override
                protected void action() throws Exception {
                    debugProcess.createFreezeThreadCommand(thread).run();
                    debuggerTreeNode.calcValue();
                }
            });
        }
    }
}
Also used : DebuggerTreeNodeImpl(com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl) DebuggerCommandImpl(com.intellij.debugger.engine.events.DebuggerCommandImpl) DebugProcessImpl(com.intellij.debugger.engine.DebugProcessImpl) ThreadDescriptorImpl(com.intellij.debugger.ui.impl.watch.ThreadDescriptorImpl) DebuggerContextImpl(com.intellij.debugger.impl.DebuggerContextImpl) ThreadReferenceProxyImpl(com.intellij.debugger.jdi.ThreadReferenceProxyImpl)

Example 4 with ThreadDescriptorImpl

use of com.intellij.debugger.ui.impl.watch.ThreadDescriptorImpl in project intellij-community by JetBrains.

the class InterruptThreadAction method actionPerformed.

public void actionPerformed(final AnActionEvent e) {
    final DebuggerTreeNodeImpl[] nodes = getSelectedNodes(e.getDataContext());
    if (nodes == null) {
        return;
    }
    //noinspection ConstantConditions
    final List<ThreadReferenceProxyImpl> threadsToInterrupt = new ArrayList<>();
    for (final DebuggerTreeNodeImpl debuggerTreeNode : nodes) {
        final NodeDescriptorImpl descriptor = debuggerTreeNode.getDescriptor();
        if (descriptor instanceof ThreadDescriptorImpl) {
            threadsToInterrupt.add(((ThreadDescriptorImpl) descriptor).getThreadReference());
        }
    }
    if (!threadsToInterrupt.isEmpty()) {
        final DebuggerContextImpl debuggerContext = getDebuggerContext(e.getDataContext());
        final DebugProcessImpl debugProcess = debuggerContext.getDebugProcess();
        if (debugProcess != null) {
            debugProcess.getManagerThread().schedule(new DebuggerCommandImpl() {

                protected void action() throws Exception {
                    boolean unsupported = false;
                    for (ThreadReferenceProxyImpl thread : threadsToInterrupt) {
                        try {
                            thread.getThreadReference().interrupt();
                        } catch (UnsupportedOperationException ignored) {
                            unsupported = true;
                        }
                    }
                    if (unsupported) {
                        final Project project = debugProcess.getProject();
                        XDebugSessionImpl.NOTIFICATION_GROUP.createNotification("Thread operation 'interrupt' is not supported by VM", MessageType.INFO).notify(project);
                    }
                }
            });
        }
    }
}
Also used : DebuggerTreeNodeImpl(com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl) ArrayList(java.util.ArrayList) ThreadDescriptorImpl(com.intellij.debugger.ui.impl.watch.ThreadDescriptorImpl) ThreadReferenceProxyImpl(com.intellij.debugger.jdi.ThreadReferenceProxyImpl) Project(com.intellij.openapi.project.Project) DebuggerCommandImpl(com.intellij.debugger.engine.events.DebuggerCommandImpl) DebugProcessImpl(com.intellij.debugger.engine.DebugProcessImpl) DebuggerContextImpl(com.intellij.debugger.impl.DebuggerContextImpl) NodeDescriptorImpl(com.intellij.debugger.ui.impl.watch.NodeDescriptorImpl)

Example 5 with ThreadDescriptorImpl

use of com.intellij.debugger.ui.impl.watch.ThreadDescriptorImpl in project intellij-community by JetBrains.

the class PopFrameAction method isAtBreakpoint.

private static boolean isAtBreakpoint(AnActionEvent e) {
    DebuggerTreeNodeImpl selectedNode = getSelectedNode(e.getDataContext());
    if (selectedNode != null && selectedNode.getDescriptor() instanceof StackFrameDescriptorImpl) {
        DebuggerTreeNodeImpl parent = selectedNode.getParent();
        if (parent != null) {
            return ((ThreadDescriptorImpl) parent.getDescriptor()).isAtBreakpoint();
        }
    }
    DebuggerContextImpl debuggerContext = DebuggerAction.getDebuggerContext(e.getDataContext());
    SuspendContextImpl suspendContext = debuggerContext.getSuspendContext();
    return suspendContext != null && debuggerContext.getThreadProxy() == suspendContext.getThread();
}
Also used : DebuggerTreeNodeImpl(com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl) StackFrameDescriptorImpl(com.intellij.debugger.ui.impl.watch.StackFrameDescriptorImpl) ThreadDescriptorImpl(com.intellij.debugger.ui.impl.watch.ThreadDescriptorImpl) SuspendContextImpl(com.intellij.debugger.engine.SuspendContextImpl) DebuggerContextImpl(com.intellij.debugger.impl.DebuggerContextImpl)

Aggregations

DebuggerTreeNodeImpl (com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl)7 ThreadDescriptorImpl (com.intellij.debugger.ui.impl.watch.ThreadDescriptorImpl)7 DebugProcessImpl (com.intellij.debugger.engine.DebugProcessImpl)4 DebuggerContextImpl (com.intellij.debugger.impl.DebuggerContextImpl)4 NodeDescriptorImpl (com.intellij.debugger.ui.impl.watch.NodeDescriptorImpl)4 DebuggerCommandImpl (com.intellij.debugger.engine.events.DebuggerCommandImpl)3 ThreadReferenceProxyImpl (com.intellij.debugger.jdi.ThreadReferenceProxyImpl)3 SuspendContextImpl (com.intellij.debugger.engine.SuspendContextImpl)2 Presentation (com.intellij.openapi.actionSystem.Presentation)2 StackFrameDescriptorImpl (com.intellij.debugger.ui.impl.watch.StackFrameDescriptorImpl)1 Project (com.intellij.openapi.project.Project)1 ArrayList (java.util.ArrayList)1