void (@NotNull Editor editor, @NotNull Project project, @NotNull List<? extends TokenBuffer.TokenInfo> tokens, @NotNull EditorHyperlinkSupport hyperlinks, @NotNull Collection<? super ConsoleViewContentType> contentTypes, @NotNull List<? super Pair<String, ConsoleViewContentType>> contents) { // add token information as range markers // start from the end because portion of the text can be stripped from the document beginning because of a cycle buffer int offset = editor.getDocument().getTextLength(); int tokenLength = 0; for (int i = tokens.size() - 1; i >= 0; i--) { TokenBuffer.TokenInfo token = tokens.get(i); contentTypes.add(token.contentType); contents.add(new Pair<>(token.getText(), token.contentType)); tokenLength += token.length(); TokenBuffer.TokenInfo prevToken = i == 0 ? null : tokens.get(i - 1); if (prevToken != null && token.contentType == prevToken.contentType && token.getHyperlinkInfo() == prevToken.getHyperlinkInfo()) { // do not create highlighter yet because can merge previous token with the current continue; } int start = Math.max(0, offset - tokenLength); if (start == offset) { continue; } HyperlinkInfo info = token.getHyperlinkInfo(); if (info != null) { hyperlinks.createHyperlink(start, offset, null, info).putUserData(MANUAL_HYPERLINK, true); } createTokenRangeHighlighter(editor, project, token.contentType, start, offset, false); offset = start; tokenLength = 0; } }