Search in sources :

Example 1 with DebuggerTreeNode

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

the class ShowAllAs method update.

public void update(AnActionEvent e) {
    DebuggerTreeNode selectedNode = ((DebuggerUtilsEx) DebuggerUtils.getInstance()).getSelectedNode(e.getDataContext());
    e.getPresentation().setVisible(myRenderer != null && selectedNode != null && isPrimitiveArray(selectedNode));
}
Also used : DebuggerTreeNode(com.intellij.debugger.ui.tree.DebuggerTreeNode) DebuggerUtilsEx(com.intellij.debugger.impl.DebuggerUtilsEx)

Example 2 with DebuggerTreeNode

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

the class ArrayRenderer method buildChildren.

public void buildChildren(Value value, ChildrenBuilder builder, EvaluationContext evaluationContext) {
    DebuggerManagerThreadImpl.assertIsManagerThread();
    List<DebuggerTreeNode> children = new ArrayList<>();
    NodeManagerImpl nodeManager = (NodeManagerImpl) builder.getNodeManager();
    NodeDescriptorFactory descriptorFactory = builder.getDescriptorManager();
    if (!myForced) {
        builder.initChildrenArrayRenderer(this);
    }
    ArrayReference array = (ArrayReference) value;
    if (array.length() > 0) {
        int added = 0;
        if (ENTRIES_LIMIT > END_INDEX - START_INDEX + 1) {
            ENTRIES_LIMIT = END_INDEX - START_INDEX;
        }
        if (ENTRIES_LIMIT <= 0) {
            ENTRIES_LIMIT = 1;
        }
        if (array.length() - 1 >= START_INDEX) {
            int start = START_INDEX;
            int end = array.length() - 1 < END_INDEX ? array.length() - 1 : END_INDEX;
            int idx;
            for (idx = start; idx <= end; idx++) {
                if (ViewsGeneralSettings.getInstance().HIDE_NULL_ARRAY_ELEMENTS && elementIsNull(array, idx))
                    continue;
                DebuggerTreeNode arrayItemNode = nodeManager.createNode(descriptorFactory.getArrayItemDescriptor(builder.getParentDescriptor(), array, idx), evaluationContext);
                if (arrayItemNode == null)
                    continue;
                //if(added >= (ENTRIES_LIMIT  + 1)/ 2) break;
                children.add(arrayItemNode);
                added++;
            }
            start = idx;
        //List<DebuggerTreeNode> childrenTail = new ArrayList<DebuggerTreeNode>();
        //for (idx = end; idx >= start; idx--) {
        //  DebuggerTreeNode arrayItemNode = nodeManager.createNode(descriptorFactory.getArrayItemDescriptor(builder.getParentDescriptor(), array, idx), evaluationContext);
        //
        //  if (arrayItemNode == null) continue;
        //  if (ViewsGeneralSettings.getInstance().HIDE_NULL_ARRAY_ELEMENTS && ((ValueDescriptorImpl)arrayItemNode.getDescriptor()).isNull()) continue;
        //  if(added >= ENTRIES_LIMIT) break;
        //  childrenTail.add(arrayItemNode);
        //  added++;
        //}
        //array is printed in the following way
        // ...
        // items1...itemENTRIES_LIMIT/2
        // ...
        // itemENTRIES_LIMIT/2+1...itemENTRIES_LIMIT
        // ...
        //when itemENTRIES_LIMIT/2+1...itemENTRIES_LIMIT set is empty, we should not add middle "..." node
        //if(idx >= start && !(ENTRIES_LIMIT == 1 && END_INDEX < array.length())) {
        //  children.add(nodeManager.createMessageNode(new MessageDescriptor(MORE_ELEMENTS, MessageDescriptor.SPECIAL)));
        //}
        //for (ListIterator<DebuggerTreeNode> iterator = childrenTail.listIterator(childrenTail.size()); iterator.hasPrevious();) {
        //  DebuggerTreeNode debuggerTreeNode = iterator.previous();
        //  children.add(debuggerTreeNode);
        //}
        }
        if (added == 0) {
            if (START_INDEX == 0 && array.length() - 1 <= END_INDEX) {
                children.add(nodeManager.createMessageNode(MessageDescriptor.ALL_ELEMENTS_IN_RANGE_ARE_NULL));
            } else {
                children.add(nodeManager.createMessageNode(DebuggerBundle.message("message.node.all.array.elements.null", START_INDEX, END_INDEX)));
            }
        } else {
            if (!myForced && END_INDEX < array.length() - 1) {
                //children.add(nodeManager.createMessageNode(new MessageDescriptor(MORE_ELEMENTS, MessageDescriptor.SPECIAL)));
                builder.setRemaining(array.length() - 1 - END_INDEX);
            }
        }
    }
    builder.setChildren(children);
}
Also used : DebuggerTreeNode(com.intellij.debugger.ui.tree.DebuggerTreeNode) ArrayReference(com.sun.jdi.ArrayReference) ArrayList(java.util.ArrayList) NodeDescriptorFactory(com.intellij.debugger.ui.tree.NodeDescriptorFactory) NodeManagerImpl(com.intellij.debugger.ui.impl.watch.NodeManagerImpl)

Example 3 with DebuggerTreeNode

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

Aggregations

DebuggerTreeNode (com.intellij.debugger.ui.tree.DebuggerTreeNode)3 DebuggerContext (com.intellij.debugger.DebuggerContext)1 SuspendContext (com.intellij.debugger.engine.SuspendContext)1 SuspendContextCommand (com.intellij.debugger.engine.managerThread.SuspendContextCommand)1 DebuggerUtilsEx (com.intellij.debugger.impl.DebuggerUtilsEx)1 DebuggerTreeNodeImpl (com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl)1 NodeManagerImpl (com.intellij.debugger.ui.impl.watch.NodeManagerImpl)1 NodeDescriptorFactory (com.intellij.debugger.ui.tree.NodeDescriptorFactory)1 ValueDescriptor (com.intellij.debugger.ui.tree.ValueDescriptor)1 ArrayReference (com.sun.jdi.ArrayReference)1 ArrayList (java.util.ArrayList)1 Enumeration (java.util.Enumeration)1