int[] (StringBuilder sb, List<? extends Pair<String, ? extends HighlightInfo>> list, int index, String text, int endPos, int startPos, boolean showAttributesKeys, boolean showTooltip) { int i = index; while (i < list.size()) { Pair<String, ? extends HighlightInfo> pair = list.get(i); HighlightInfo info = pair.second; if (info.endOffset <= startPos) { break; } String severity = pair.first; HighlightInfo prev = i < list.size() - 1 ? list.get(i + 1).second : null; sb.insert(0, text.substring(info.endOffset, endPos)); sb.insert(0, "</" + severity + '>'); endPos = info.endOffset; if (prev != null && prev.endOffset > info.startOffset) { int[] offsets = composeText(sb, list, i + 1, text, endPos, info.startOffset, showAttributesKeys, showTooltip); i = offsets[0] - 1; endPos = offsets[1]; } sb.insert(0, text.substring(info.startOffset, endPos)); StringBuilder str = new StringBuilder().append('<').append(severity); if (info.getSeverity() != HighlightInfoType.HIGHLIGHTED_REFERENCE_SEVERITY) { String description = info.getDescription(); String toolTip = info.getToolTip(); str.append(" descr=\"").append(StringUtil.escapeQuotes(String.valueOf(description))).append('"'); if (showTooltip) { str.append(" tooltip=\"").append(StringUtil.escapeQuotes(String.valueOf(toolTip != null ? XmlStringUtil.stripHtml(toolTip) : null))).append('"'); } } if (showAttributesKeys) { str.append(" textAttributesKey=\"").append(ObjectUtils.notNull(info.forcedTextAttributesKey, info.type.getAttributesKey()).getExternalName()).append('"'); } str.append('>'); sb.insert(0, str); endPos = info.startOffset; i++; } return new int[]{i, endPos}; }