String (String text, List<? super HighlightData> highlights) { mySkipped.clear(); if (ContainerUtil.isEmpty(myTags) && ContainerUtil.isEmpty(myInlineElements)) return text; resetIndices(); Stack<HighlightData> highlightsStack = new Stack<>(); while (true) { String tagName = findTagName(text); if (tagName == null || myIndex < 0) break; String tagNameWithoutParameters = StringUtil.substringBefore(tagName, " "); ColorKey additionalColorKey = myAdditionalColorKeyMap == null ? null : myAdditionalColorKeyMap.get(tagNameWithoutParameters == null ? tagName : tagNameWithoutParameters); if (myInlineElements != null && tagNameWithoutParameters != null && myInlineElements.containsKey(tagNameWithoutParameters)) { mySkippedLen += tagName.length() + 2; String hintText = tagName.substring(tagNameWithoutParameters.length()).trim(); highlights.add(new InlineElementData(myStartOffset - mySkippedLen, myInlineElements.get(tagNameWithoutParameters), hintText, additionalColorKey)); } else if (myTags != null && myTags.containsKey(tagName)) { if (myIsOpeningTag) { mySkippedLen += tagName.length() + 2; HighlightData highlightData = new HighlightData(myStartOffset - mySkippedLen, myTags.get(tagName), additionalColorKey); highlightsStack.push(highlightData); } else { HighlightData highlightData = highlightsStack.pop(); highlightData.setEndOffset(myEndOffset - mySkippedLen); mySkippedLen += tagName.length() + 3; highlights.add(highlightData); } } } return cutDefinedTags(text); }