SimpleColoredText (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.getCollectingDataMessage())) { descriptorText.append(XDebuggerUIConstants.getCollectingDataMessage(), XDebuggerUIConstants.COLLECTING_DATA_HIGHLIGHT_ATTRIBUTES); return descriptorText; } 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 valueDescriptor) { if (multiline && strings[2].indexOf('\n') >= 0) { strings = breakString(strings[2], "="); if (strings[2] != null) { strings[2] = strings[0] + strings[1] + "\n" + strings[2]; } } 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(); final String valueText; if (valueLabel.endsWith(errorMessage)) { valueText = valueLabel.substring(0, valueLabel.length() - errorMessage.length()); } else { valueText = valueLabel; } appendValueTextWithEscapesRendering(descriptorText, valueText, valueLabelAttribs, colorScheme); descriptorText.append(errorMessage, XDebuggerUIConstants.EXCEPTION_ATTRIBUTES); } else { if (valueLabel.equals(XDebuggerUIConstants.getCollectingDataMessage())) { descriptorText.append(XDebuggerUIConstants.getCollectingDataMessage(), XDebuggerUIConstants.COLLECTING_DATA_HIGHLIGHT_ATTRIBUTES); } else { appendValueTextWithEscapesRendering(descriptorText, valueLabel, valueLabelAttribs, colorScheme); } } } }