void (@NotNull @NlsSafe String value, @NotNull ColoredTextContainer text, @NotNull SimpleTextAttributes attributes, int maxLength, @Nullable String additionalCharsToEscape) { SimpleTextAttributes escapeAttributes = null; int lastOffset = 0; int length = maxLength == -1 ? value.length() : Math.min(value.length(), maxLength); for (int i = 0; i < length; i++) { char ch = value.charAt(i); int additionalCharIndex = -1; if (ch == '\n' || ch == '\r' || ch == '\t' || ch == '\b' || ch == '\f' || (additionalCharsToEscape != null && (additionalCharIndex = additionalCharsToEscape.indexOf(ch)) != -1)) { if (i > lastOffset) { text.append(value.substring(lastOffset, i), attributes); } lastOffset = i + 1; if (escapeAttributes == null) { TextAttributes fromHighlighter = DebuggerUIUtil.getColorScheme().getAttributes(DefaultLanguageHighlighterColors.VALID_STRING_ESCAPE); if (fromHighlighter != null) { escapeAttributes = SimpleTextAttributes.fromTextAttributes(fromHighlighter); } else { escapeAttributes = new SimpleTextAttributes(SimpleTextAttributes.STYLE_BOLD, JBColor.GRAY); } } if (additionalCharIndex == -1) { text.append("\\", escapeAttributes); } text.append(String.valueOf(getEscapingSymbol(ch)), escapeAttributes); } } if (lastOffset < length) { text.append(value.substring(lastOffset, length), attributes); } }