Search in sources :

Example 21 with DebuggerTreeNodeImpl

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

the class ResumeThreadAction method update.

public void update(AnActionEvent e) {
    DebuggerTreeNodeImpl[] selectedNodes = getSelectedNodes(e.getDataContext());
    boolean visible = false;
    boolean enabled = false;
    String text = DebuggerBundle.message("action.resume.thread.text.resume");
    if (selectedNodes != null && selectedNodes.length > 0) {
        visible = true;
        enabled = true;
        for (DebuggerTreeNodeImpl selectedNode : selectedNodes) {
            final NodeDescriptorImpl threadDescriptor = selectedNode.getDescriptor();
            if (!(threadDescriptor instanceof ThreadDescriptorImpl) || !((ThreadDescriptorImpl) threadDescriptor).isSuspended()) {
                visible = false;
                break;
            }
        }
    }
    final Presentation presentation = e.getPresentation();
    presentation.setText(text);
    presentation.setVisible(visible);
    presentation.setEnabled(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 22 with DebuggerTreeNodeImpl

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

the class ResumeThreadAction method actionPerformed.

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

                @Override
                protected void action() throws Exception {
                    SuspendContextImpl suspendingContext = SuspendManagerUtil.getSuspendingContext(debugProcess.getSuspendManager(), thread);
                    if (suspendingContext != null) {
                        debugProcess.createResumeThreadCommand(suspendingContext, 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) SuspendContextImpl(com.intellij.debugger.engine.SuspendContextImpl) DebuggerContextImpl(com.intellij.debugger.impl.DebuggerContextImpl) ThreadReferenceProxyImpl(com.intellij.debugger.jdi.ThreadReferenceProxyImpl)

Example 23 with DebuggerTreeNodeImpl

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

the class ShowAllAs method actionPerformed.

public void actionPerformed(AnActionEvent e) {
    DebuggerTreeNodeImpl selectedNode = (DebuggerTreeNodeImpl) ((DebuggerUtilsEx) DebuggerUtils.getInstance()).getSelectedNode(e.getDataContext());
    if (selectedNode == null)
        return;
    if (!isPrimitiveArray(selectedNode))
        return;
    final DebuggerContext debuggerContext = DebuggerUtils.getInstance().getDebuggerContext(e.getDataContext());
    if (debuggerContext == null || debuggerContext.getDebugProcess() == null)
        return;
    for (Enumeration children = selectedNode.children(); children.hasMoreElements(); ) {
        final DebuggerTreeNode child = (DebuggerTreeNode) children.nextElement();
        if (child.getDescriptor() instanceof ValueDescriptor) {
            debuggerContext.getDebugProcess().getManagerThread().invokeCommand(new SuspendContextCommand() {

                public SuspendContext getSuspendContext() {
                    return debuggerContext.getSuspendContext();
                }

                public void action() {
                    child.setRenderer(myRenderer);
                }

                public void commandCancelled() {
                }
            });
        }
    }
}
Also used : SuspendContextCommand(com.intellij.debugger.engine.managerThread.SuspendContextCommand) DebuggerTreeNode(com.intellij.debugger.ui.tree.DebuggerTreeNode) DebuggerTreeNodeImpl(com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl) Enumeration(java.util.Enumeration) ValueDescriptor(com.intellij.debugger.ui.tree.ValueDescriptor) DebuggerContext(com.intellij.debugger.DebuggerContext) SuspendContext(com.intellij.debugger.engine.SuspendContext)

Example 24 with DebuggerTreeNodeImpl

use of com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl in project android by JetBrains.

the class InstancesTreeView method getTargetFiles.

@Nullable
private PsiClassNavigation[] getTargetFiles() {
    Object node = myDebuggerTree.getSelectionPath().getLastPathComponent();
    String className = null;
    if (node instanceof DebuggerTreeNodeImpl) {
        NodeDescriptorImpl nodeDescriptor = ((DebuggerTreeNodeImpl) node).getDescriptor();
        if (nodeDescriptor instanceof InstanceFieldDescriptorImpl) {
            Instance instance = ((InstanceFieldDescriptorImpl) nodeDescriptor).getInstance();
            if (instance != null) {
                if (instance instanceof ClassObj) {
                    className = ((ClassObj) instance).getClassName();
                } else {
                    className = instance.getClassObj().getClassName();
                    if (instance instanceof ArrayInstance) {
                        className = className.replace("[]", "");
                    }
                }
            }
        }
    }
    return PsiClassNavigation.getNavigationForClass(myProject, className);
}
Also used : DebuggerTreeNodeImpl(com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl) NodeDescriptorImpl(com.intellij.debugger.ui.impl.watch.NodeDescriptorImpl) Nullable(org.jetbrains.annotations.Nullable)

Example 25 with DebuggerTreeNodeImpl

use of com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl in project android by JetBrains.

the class InstancesTreeView method expandMoreNodesUntilFound.

@Nullable
private DebuggerTreeNodeImpl expandMoreNodesUntilFound(@NotNull DebuggerTreeNodeImpl node, @NotNull Instance targetInstance) {
    if (node.getDescriptor() instanceof ContainerDescriptorImpl) {
        int startIndex = 0;
        if (node.getChildCount() > 0) {
            DebuggerTreeNodeImpl lastNode = (DebuggerTreeNodeImpl) node.getChildAt(node.getChildCount() - 1);
            if (lastNode.getDescriptor() instanceof ExpansionDescriptorImpl) {
                lastNode.removeFromParent();
                startIndex = node.getChildCount() - 1;
            } else {
                for (int scanIndex = 0; scanIndex < node.getChildCount(); ++scanIndex) {
                    DebuggerTreeNodeImpl scanNode = (DebuggerTreeNodeImpl) node.getChildAt(scanIndex);
                    NodeDescriptor nodeDescriptor = scanNode.getDescriptor();
                    if (nodeDescriptor instanceof InstanceFieldDescriptorImpl && ((InstanceFieldDescriptorImpl) nodeDescriptor).getInstance() == targetInstance) {
                        return scanNode;
                    }
                }
                return null;
            }
        }
        int maxSize = ((ContainerDescriptorImpl) node.getDescriptor()).getInstances().size();
        while (startIndex < maxSize) {
            addContainerChildren(node, startIndex, false);
            for (int scanIndex = startIndex; scanIndex < node.getChildCount(); ++scanIndex) {
                DebuggerTreeNodeImpl scanNode = (DebuggerTreeNodeImpl) node.getChildAt(scanIndex);
                NodeDescriptor nodeDescriptor = scanNode.getDescriptor();
                if (nodeDescriptor instanceof InstanceFieldDescriptorImpl && ((InstanceFieldDescriptorImpl) nodeDescriptor).getInstance() == targetInstance) {
                    addExpansionNode(node, node.getChildCount(), maxSize);
                    return scanNode;
                }
            }
            startIndex = node.getChildCount();
        }
    }
    return null;
}
Also used : DebuggerTreeNodeImpl(com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl) DefaultNodeDescriptor(com.intellij.debugger.ui.impl.watch.DefaultNodeDescriptor) NodeDescriptor(com.intellij.debugger.ui.tree.NodeDescriptor) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

DebuggerTreeNodeImpl (com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl)26 DebuggerContextImpl (com.intellij.debugger.impl.DebuggerContextImpl)11 NodeDescriptorImpl (com.intellij.debugger.ui.impl.watch.NodeDescriptorImpl)10 DebugProcessImpl (com.intellij.debugger.engine.DebugProcessImpl)9 ThreadDescriptorImpl (com.intellij.debugger.ui.impl.watch.ThreadDescriptorImpl)7 ValueDescriptor (com.intellij.debugger.ui.tree.ValueDescriptor)6 Nullable (org.jetbrains.annotations.Nullable)6 DebuggerContextCommandImpl (com.intellij.debugger.engine.events.DebuggerContextCommandImpl)5 Project (com.intellij.openapi.project.Project)5 SourcePosition (com.intellij.debugger.SourcePosition)4 DebuggerTree (com.intellij.debugger.ui.impl.watch.DebuggerTree)4 DebuggerCommandImpl (com.intellij.debugger.engine.events.DebuggerCommandImpl)3 ThreadReferenceProxyImpl (com.intellij.debugger.jdi.ThreadReferenceProxyImpl)3 Presentation (com.intellij.openapi.actionSystem.Presentation)3 SuspendContextImpl (com.intellij.debugger.engine.SuspendContextImpl)2 DebuggerSession (com.intellij.debugger.impl.DebuggerSession)2 FieldDescriptorImpl (com.intellij.debugger.ui.impl.watch.FieldDescriptorImpl)2 ValueDescriptorImpl (com.intellij.debugger.ui.impl.watch.ValueDescriptorImpl)2 NodeDescriptor (com.intellij.debugger.ui.tree.NodeDescriptor)2 Document (com.intellij.openapi.editor.Document)2