String (@NotNull HighlighterIterator iterator) { CharSequence text = iterator.getDocument().getCharsSequence(); StringBuilder result = new StringBuilder(); IElementType tokenType; while (!iterator.atEnd()) { tokenType = iterator.getTokenType(); result.append(printSingleToken(text, tokenType, iterator.getStart(), iterator.getEnd())); iterator.advance(); } return result.toString(); }