void (SimpleColoredText descriptorText, String valueText, SimpleTextAttributes attribs, EditorColorsScheme colorScheme) { SimpleTextAttributes escapeAttribs = null; final @NlsSafe StringBuilder buf = new StringBuilder(); boolean slashFound = false; for (int idx = 0; idx < valueText.length(); idx++) { final char ch = valueText.charAt(idx); if (slashFound) { slashFound = false; if (ch == '\\' || ch == '\"' || ch == 'b' || ch == 't' || ch == 'n' || ch == 'f' || ch == 'r') { if (!buf.isEmpty()) { descriptorText.append(buf.toString(), attribs); buf.setLength(0); } if (escapeAttribs == null) { // lazy init TextAttributes fromHighlighter = colorScheme.getAttributes(JavaHighlightingColors.VALID_STRING_ESCAPE); if (fromHighlighter != null) { escapeAttribs = SimpleTextAttributes.fromTextAttributes(fromHighlighter); } else { escapeAttribs = DEFAULT_ATTRIBUTES.derive(SimpleTextAttributes.STYLE_BOLD, JBColor.GRAY, null, null); } } if (ch != '\\' && ch != '\"') { descriptorText.append("\\", escapeAttribs); } descriptorText.append(String.valueOf(ch), escapeAttribs); } else { buf.append('\\').append(ch); } } else { if (ch == '\\') { slashFound = true; } else { buf.append(ch); } } } if (!buf.isEmpty()) { descriptorText.append(buf.toString(), attribs); } }