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;
}
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;
}
}
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;
}
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();
}
});
}
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);
}
}
Aggregations