void (@NotNull Editor editor, @NotNull Project project, @NotNull ConsoleViewContentType contentType, int startOffset, int endOffset, boolean mergeWithThePreviousSameTypeToken) { ThreadingAssertions.assertEventDispatchThread(); MarkupModelEx model = (MarkupModelEx)DocumentMarkupModel.forDocument(editor.getDocument(), project, true); int layer = HighlighterLayer.SYNTAX + 1; // make custom filters able to draw their text attributes over the default ones if (mergeWithThePreviousSameTypeToken && startOffset > 0) { RangeMarker prevMarker = findTokenMarker(editor, project, startOffset - 1); ConsoleViewContentType prevMarkerType = prevMarker == null ? null : getTokenType(prevMarker); int prevMarkerEndOffset = prevMarkerType == null ? -1 : prevMarker.getEndOffset(); if (contentType.equals(prevMarkerType) && prevMarkerEndOffset >= 0 && prevMarkerEndOffset < editor.getDocument().getTextLength() && // must not merge tokens with end line because user input should be separated by new lines editor.getDocument().getCharsSequence().charAt(prevMarkerEndOffset - 1) != '\n') { startOffset = prevMarker.getStartOffset(); prevMarker.dispose(); } } model.addRangeHighlighterAndChangeAttributes( contentType.getAttributesKey(), startOffset, endOffset, layer, HighlighterTargetArea.EXACT_RANGE, false, rm -> { // fallback for contentTypes which provide only attributes if (rm.getTextAttributesKey() == null) { rm.setTextAttributes(contentType.getAttributes()); } saveTokenType(rm, contentType); }); }