Search in sources :

Example 1 with NodeDescriptor

use of com.intellij.debugger.ui.tree.NodeDescriptor in project intellij-community by JetBrains.

the class DescriptorTestCase method expandAll.

protected void expandAll(final Tree tree, final Runnable runnable, final Set<Value> alreadyExpanded, final NodeFilter filter, final SuspendContextImpl context) {
    invokeRatherLater(context, () -> {
        boolean anyCollapsed = false;
        for (int i = 0; i < tree.getRowCount(); i++) {
            final TreeNode treeNode = (TreeNode) tree.getPathForRow(i).getLastPathComponent();
            if (tree.isCollapsed(i) && !treeNode.isLeaf()) {
                NodeDescriptor nodeDescriptor = null;
                if (treeNode instanceof DebuggerTreeNodeImpl) {
                    nodeDescriptor = ((DebuggerTreeNodeImpl) treeNode).getDescriptor();
                }
                boolean shouldExpand = filter == null || filter.shouldExpand(treeNode);
                if (shouldExpand) {
                    // additional checks to prevent infinite expand
                    if (nodeDescriptor instanceof ValueDescriptor) {
                        final Value value = ((ValueDescriptor) nodeDescriptor).getValue();
                        shouldExpand = !alreadyExpanded.contains(value);
                        if (shouldExpand) {
                            alreadyExpanded.add(value);
                        }
                    }
                }
                if (shouldExpand) {
                    anyCollapsed = true;
                    tree.expandRow(i);
                }
            }
        }
        if (anyCollapsed) {
            expandAll(tree, runnable, alreadyExpanded, filter, context);
        } else {
            runnable.run();
        }
    });
}
Also used : DebuggerTreeNodeImpl(com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl) TreeNode(javax.swing.tree.TreeNode) ValueDescriptor(com.intellij.debugger.ui.tree.ValueDescriptor) NodeDescriptor(com.intellij.debugger.ui.tree.NodeDescriptor) Value(com.sun.jdi.Value)

Example 2 with NodeDescriptor

use of com.intellij.debugger.ui.tree.NodeDescriptor in project intellij-community by JetBrains.

the class InstancesTree method getSelectedReference.

@Nullable
ObjectReference getSelectedReference() {
    TreePath selectionPath = getSelectionPath();
    Object selectedItem = selectionPath != null ? selectionPath.getLastPathComponent() : null;
    if (selectedItem instanceof XValueNodeImpl) {
        XValueNodeImpl xValueNode = (XValueNodeImpl) selectedItem;
        XValue valueContainer = xValueNode.getValueContainer();
        if (valueContainer instanceof NodeDescriptorProvider) {
            NodeDescriptor descriptor = ((NodeDescriptorProvider) valueContainer).getDescriptor();
            if (descriptor instanceof ValueDescriptor) {
                Value value = ((ValueDescriptor) descriptor).getValue();
                if (value instanceof ObjectReference)
                    return (ObjectReference) value;
            }
        }
    }
    return null;
}
Also used : NodeDescriptorProvider(com.intellij.debugger.ui.impl.watch.NodeDescriptorProvider) TreePath(javax.swing.tree.TreePath) ObjectReference(com.sun.jdi.ObjectReference) ValueDescriptor(com.intellij.debugger.ui.tree.ValueDescriptor) XValueNodeImpl(com.intellij.xdebugger.impl.ui.tree.nodes.XValueNodeImpl) NodeDescriptor(com.intellij.debugger.ui.tree.NodeDescriptor) Value(com.sun.jdi.Value) Nullable(org.jetbrains.annotations.Nullable)

Example 3 with NodeDescriptor

use of com.intellij.debugger.ui.tree.NodeDescriptor in project intellij-community by JetBrains.

the class DescriptorTree method dfstImpl.

private void dfstImpl(NodeDescriptor descriptor, List<NodeDescriptor> children, DFSTWalker walker) {
    if (children != null) {
        for (NodeDescriptor child : children) {
            walker.visit(descriptor, child);
            dfstImpl(child, myChildrenMap.get(child), walker);
        }
    }
}
Also used : NodeDescriptor(com.intellij.debugger.ui.tree.NodeDescriptor)

Example 4 with NodeDescriptor

use of com.intellij.debugger.ui.tree.NodeDescriptor 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

NodeDescriptor (com.intellij.debugger.ui.tree.NodeDescriptor)4 DebuggerTreeNodeImpl (com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl)2 ValueDescriptor (com.intellij.debugger.ui.tree.ValueDescriptor)2 Value (com.sun.jdi.Value)2 Nullable (org.jetbrains.annotations.Nullable)2 DefaultNodeDescriptor (com.intellij.debugger.ui.impl.watch.DefaultNodeDescriptor)1 NodeDescriptorProvider (com.intellij.debugger.ui.impl.watch.NodeDescriptorProvider)1 XValueNodeImpl (com.intellij.xdebugger.impl.ui.tree.nodes.XValueNodeImpl)1 ObjectReference (com.sun.jdi.ObjectReference)1 TreeNode (javax.swing.tree.TreeNode)1 TreePath (javax.swing.tree.TreePath)1