Search in sources :

Example 1 with NodeDescriptorFactory

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

Aggregations

NodeManagerImpl (com.intellij.debugger.ui.impl.watch.NodeManagerImpl)1 DebuggerTreeNode (com.intellij.debugger.ui.tree.DebuggerTreeNode)1 NodeDescriptorFactory (com.intellij.debugger.ui.tree.NodeDescriptorFactory)1 ArrayReference (com.sun.jdi.ArrayReference)1 ArrayList (java.util.ArrayList)1