Search in sources :

Example 1 with MessageDescriptor

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

the class ArrayMapRendererBase method buildChildren.

/** Builds a list of {@link DebuggerTreeNode}'s that are the children of this node. */
@Override
public void buildChildren(Value value, ChildrenBuilder builder, EvaluationContext evaluationContext) {
    DebuggerManagerThreadImpl.assertIsManagerThread();
    List<DebuggerTreeNode> children = new ArrayList<DebuggerTreeNode>();
    NodeManagerImpl nodeManager = (NodeManagerImpl) builder.getNodeManager();
    NodeDescriptorFactory descriptorFactory = builder.getDescriptorManager();
    int size;
    try {
        size = getArrayMapSize(value, evaluationContext);
    } catch (Exception e) {
        size = 0;
    }
    for (int i = 0, n = Math.min(size, MAX_CHILDREN); i < n; i++) {
        // For each entry, display the value at that entry. TODO: we need to show the key corresponding to this as well.
        // We used to show the key and value by using the following expression:
        // String expression = String.format("new Object[] {this.keyAt(%1$d), this.valueAt(%2$d)}", i, i);
        // But it turns out that this throws "java.lang.ClassNotFoundException: [LObject;"
        // Until we find an alternate scheme, just show the value.
        String expression = String.format("this.valueAt(%1$d)", i);
        UserExpressionData descriptorData = new UserExpressionData((ValueDescriptorImpl) builder.getParentDescriptor(), myFqn, String.format("value[%1$d]", i), new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, expression, "", StdFileTypes.JAVA));
        UserExpressionDescriptor userExpressionDescriptor = descriptorFactory.getUserExpressionDescriptor(builder.getParentDescriptor(), descriptorData);
        DebuggerTreeNode arrayMapItemNode = nodeManager.createNode(userExpressionDescriptor, evaluationContext);
        children.add(arrayMapItemNode);
    }
    if (size > MAX_CHILDREN) {
        children.add(nodeManager.createMessageNode(new MessageDescriptor(MORE_ELEMENTS, MessageDescriptor.SPECIAL)));
    }
    builder.setChildren(children);
}
Also used : MessageDescriptor(com.intellij.debugger.ui.impl.watch.MessageDescriptor) UserExpressionData(com.intellij.debugger.impl.descriptors.data.UserExpressionData) ArrayList(java.util.ArrayList) TextWithImportsImpl(com.intellij.debugger.engine.evaluation.TextWithImportsImpl) NodeManagerImpl(com.intellij.debugger.ui.impl.watch.NodeManagerImpl) EvaluateException(com.intellij.debugger.engine.evaluation.EvaluateException)

Aggregations

EvaluateException (com.intellij.debugger.engine.evaluation.EvaluateException)1 TextWithImportsImpl (com.intellij.debugger.engine.evaluation.TextWithImportsImpl)1 UserExpressionData (com.intellij.debugger.impl.descriptors.data.UserExpressionData)1 MessageDescriptor (com.intellij.debugger.ui.impl.watch.MessageDescriptor)1 NodeManagerImpl (com.intellij.debugger.ui.impl.watch.NodeManagerImpl)1 ArrayList (java.util.ArrayList)1