Search in sources :

Example 6 with ValueDescriptor

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

the class ShowAllAs method isPrimitiveArray.

private static boolean isPrimitiveArray(DebuggerTreeNode selectedNode) {
    try {
        if (selectedNode.getDescriptor() instanceof ValueDescriptor) {
            ValueDescriptor valueDescriptor = ((ValueDescriptor) selectedNode.getDescriptor());
            if (valueDescriptor.isArray()) {
                ArrayReference arrayReference = ((ArrayReference) valueDescriptor.getValue());
                Type componentType = ((ArrayType) arrayReference.type()).componentType();
                if (componentType instanceof PrimitiveType) {
                    if (componentType instanceof ByteType || componentType instanceof ShortType || componentType instanceof IntegerType || componentType instanceof LongType) {
                        return true;
                    }
                }
            }
        }
    } catch (ClassNotLoadedException ignored) {
    }
    return false;
}
Also used : ValueDescriptor(com.intellij.debugger.ui.tree.ValueDescriptor)

Example 7 with ValueDescriptor

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

the class DebuggerTreeNodeImpl method updateCaches.

private void updateCaches() {
    final NodeDescriptorImpl descriptor = getDescriptor();
    myIcon = DebuggerTreeRenderer.getDescriptorIcon(descriptor);
    final DebuggerContextImpl context = getTree().getDebuggerContext();
    myText = DebuggerTreeRenderer.getDescriptorText(context, descriptor, DebuggerUIUtil.getColorScheme(myTree), false);
    if (descriptor instanceof ValueDescriptor) {
        final ValueMarkup markup = ((ValueDescriptor) descriptor).getMarkup(context.getDebugProcess());
        myMarkupTooltipText = markup != null ? markup.getToolTipText() : null;
    } else {
        myMarkupTooltipText = null;
    }
}
Also used : ValueDescriptor(com.intellij.debugger.ui.tree.ValueDescriptor) DebuggerContextImpl(com.intellij.debugger.impl.DebuggerContextImpl) ValueMarkup(com.intellij.xdebugger.impl.ui.tree.ValueMarkup)

Example 8 with ValueDescriptor

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

the class DebuggerTreeRenderer method getDescriptorText.

private static SimpleColoredText getDescriptorText(DebuggerContextImpl debuggerContext, NodeDescriptorImpl descriptor, EditorColorsScheme colorScheme, boolean multiline, boolean appendValue) {
    SimpleColoredText descriptorText = new SimpleColoredText();
    String text;
    String nodeName;
    if (descriptor == null) {
        text = "";
        nodeName = null;
    } else {
        text = descriptor.getLabel();
        nodeName = descriptor.getName();
    }
    if (text.equals(XDebuggerUIConstants.COLLECTING_DATA_MESSAGE)) {
        descriptorText.append(XDebuggerUIConstants.COLLECTING_DATA_MESSAGE, XDebuggerUIConstants.COLLECTING_DATA_HIGHLIGHT_ATTRIBUTES);
        return descriptorText;
    }
    if (descriptor instanceof ValueDescriptor) {
        final ValueMarkup markup = ((ValueDescriptor) descriptor).getMarkup(debuggerContext.getDebugProcess());
        if (markup != null) {
            descriptorText.append("[" + markup.getText() + "] ", new SimpleTextAttributes(SimpleTextAttributes.STYLE_BOLD, markup.getColor()));
        }
    }
    String[] strings = breakString(text, nodeName);
    if (strings[0] != null) {
        if (descriptor instanceof MessageDescriptor && ((MessageDescriptor) descriptor).getKind() == MessageDescriptor.SPECIAL) {
            descriptorText.append(strings[0], SPECIAL_NODE_ATTRIBUTES);
        } else {
            descriptorText.append(strings[0], DEFAULT_ATTRIBUTES);
        }
    }
    if (strings[1] != null) {
        descriptorText.append(strings[1], XDebuggerUIConstants.VALUE_NAME_ATTRIBUTES);
    }
    if (strings[2] != null) {
        if (descriptor instanceof ValueDescriptorImpl) {
            if (multiline && strings[2].indexOf('\n') >= 0) {
                strings = breakString(strings[2], "=");
                if (strings[2] != null) {
                    strings[2] = strings[0] + strings[1] + "\n" + strings[2];
                }
            }
            ValueDescriptorImpl valueDescriptor = (ValueDescriptorImpl) descriptor;
            String valueLabel = valueDescriptor.getValueLabel();
            strings = breakString(strings[2], valueLabel);
            if (strings[0] != null) {
                descriptorText.append(strings[0], DEFAULT_ATTRIBUTES);
            }
            if (appendValue && strings[1] != null) {
                if (valueLabel != null && StringUtil.startsWithChar(valueLabel, '{') && valueLabel.indexOf('}') > 0 && !StringUtil.endsWithChar(valueLabel, '}')) {
                    int idx = valueLabel.indexOf('}');
                    String objectId = valueLabel.substring(0, idx + 1);
                    valueLabel = valueLabel.substring(idx + 1);
                    descriptorText.append(objectId, OBJECT_ID_HIGHLIGHT_ATTRIBUTES);
                }
                valueLabel = DebuggerUtilsEx.truncateString(valueLabel);
                final SimpleTextAttributes valueLabelAttribs;
                if (valueDescriptor.isDirty()) {
                    valueLabelAttribs = XDebuggerUIConstants.CHANGED_VALUE_ATTRIBUTES;
                } else {
                    TextAttributes attributes = null;
                    if (valueDescriptor.isNull()) {
                        attributes = colorScheme.getAttributes(JavaHighlightingColors.KEYWORD);
                    } else if (valueDescriptor.isString()) {
                        attributes = colorScheme.getAttributes(JavaHighlightingColors.STRING);
                    }
                    valueLabelAttribs = attributes != null ? SimpleTextAttributes.fromTextAttributes(attributes) : DEFAULT_ATTRIBUTES;
                }
                final EvaluateException exception = descriptor.getEvaluateException();
                if (exception != null) {
                    final String errorMessage = exception.getMessage();
                    if (valueLabel.endsWith(errorMessage)) {
                        appendValueTextWithEscapesRendering(descriptorText, valueLabel.substring(0, valueLabel.length() - errorMessage.length()), valueLabelAttribs, colorScheme);
                        descriptorText.append(errorMessage, XDebuggerUIConstants.EXCEPTION_ATTRIBUTES);
                    } else {
                        appendValueTextWithEscapesRendering(descriptorText, valueLabel, valueLabelAttribs, colorScheme);
                        descriptorText.append(errorMessage, XDebuggerUIConstants.EXCEPTION_ATTRIBUTES);
                    }
                } else {
                    if (valueLabel.equals(XDebuggerUIConstants.COLLECTING_DATA_MESSAGE)) {
                        descriptorText.append(XDebuggerUIConstants.COLLECTING_DATA_MESSAGE, XDebuggerUIConstants.COLLECTING_DATA_HIGHLIGHT_ATTRIBUTES);
                    } else {
                        appendValueTextWithEscapesRendering(descriptorText, valueLabel, valueLabelAttribs, colorScheme);
                    }
                }
            }
        } else {
            descriptorText.append(strings[2], DEFAULT_ATTRIBUTES);
        }
    }
    return descriptorText;
}
Also used : EvaluateException(com.intellij.debugger.engine.evaluation.EvaluateException) ValueDescriptor(com.intellij.debugger.ui.tree.ValueDescriptor) TextAttributes(com.intellij.openapi.editor.markup.TextAttributes) ValueMarkup(com.intellij.xdebugger.impl.ui.tree.ValueMarkup)

Example 9 with ValueDescriptor

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

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

the class ExpressionChildrenRenderer method buildChildren.

public void buildChildren(final Value value, final ChildrenBuilder builder, final EvaluationContext evaluationContext) {
    final NodeManager nodeManager = builder.getNodeManager();
    try {
        final ValueDescriptor parentDescriptor = builder.getParentDescriptor();
        final Value childrenValue = evaluateChildren(evaluationContext.createEvaluationContext(value), parentDescriptor);
        NodeRenderer renderer = getChildrenRenderer(childrenValue, parentDescriptor);
        renderer.buildChildren(childrenValue, builder, evaluationContext);
    } catch (final EvaluateException e) {
        List<DebuggerTreeNode> errorChildren = new ArrayList<>();
        errorChildren.add(nodeManager.createMessageNode(DebuggerBundle.message("error.unable.to.evaluate.expression") + " " + e.getMessage()));
        builder.setChildren(errorChildren);
    }
}
Also used : NodeManager(com.intellij.debugger.ui.tree.NodeManager) EvaluateException(com.intellij.debugger.engine.evaluation.EvaluateException) ValueDescriptor(com.intellij.debugger.ui.tree.ValueDescriptor) BooleanValue(com.sun.jdi.BooleanValue) Value(com.sun.jdi.Value) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

ValueDescriptor (com.intellij.debugger.ui.tree.ValueDescriptor)13 DebuggerTreeNodeImpl (com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl)6 DebuggerContextImpl (com.intellij.debugger.impl.DebuggerContextImpl)4 NodeDescriptorImpl (com.intellij.debugger.ui.impl.watch.NodeDescriptorImpl)4 DebugProcessImpl (com.intellij.debugger.engine.DebugProcessImpl)3 ValueMarkup (com.intellij.xdebugger.impl.ui.tree.ValueMarkup)3 Value (com.sun.jdi.Value)3 EvaluateException (com.intellij.debugger.engine.evaluation.EvaluateException)2 DebuggerContextCommandImpl (com.intellij.debugger.engine.events.DebuggerContextCommandImpl)2 NodeDescriptor (com.intellij.debugger.ui.tree.NodeDescriptor)2 Pair (com.intellij.openapi.util.Pair)2 HashMap (com.intellij.util.containers.HashMap)2 Patches (com.intellij.Patches)1 com.intellij.debugger (com.intellij.debugger)1 DebuggerContext (com.intellij.debugger.DebuggerContext)1 DebuggerAction (com.intellij.debugger.actions.DebuggerAction)1 DebuggerActions (com.intellij.debugger.actions.DebuggerActions)1 DebugProcess (com.intellij.debugger.engine.DebugProcess)1 SuspendContext (com.intellij.debugger.engine.SuspendContext)1 com.intellij.debugger.engine.evaluation (com.intellij.debugger.engine.evaluation)1