String (@NotNull final String text, @NotNull final TreeMap<TextRange, ParameterInfoUIContextEx.Flag> flagsMap) { final StringBuilder labelText = new StringBuilder(text); final Int2IntMap faultMap = new Int2IntOpenHashMap(); for (Map.Entry<TextRange, ParameterInfoUIContextEx.Flag> entry : flagsMap.entrySet()) { final TextRange highlightRange = entry.getKey(); final ParameterInfoUIContextEx.Flag flag = entry.getValue(); final String tagValue = getTagValue(flag); final String tag = getOpeningTag(tagValue); final String endTag = getClosingTag(tagValue); int startOffset = highlightRange.getStartOffset(); int endOffset = highlightRange.getEndOffset() + tag.length(); for (Int2IntMap.Entry entry1 : Int2IntMaps.fastIterable(faultMap)) { if (entry1.getIntKey() <= highlightRange.getStartOffset()) { startOffset += entry1.getIntValue(); endOffset += entry1.getIntValue(); } } labelText.insert(startOffset, tag); labelText.insert(endOffset, endTag); faultMap.put(startOffset, tag.length()); } return labelText.toString(); }