void (final EditorImpl editor, final int offset, final List<? extends TextAttributes> attributes) { final List<RangeHighlighterEx> list1 = new ArrayList<>(); final List<RangeHighlighterEx> list2 = new ArrayList<>(); final Processor<RangeHighlighterEx> processor = highlighter -> { if (!highlighter.isValid()) return true; final boolean isLineHighlighter = highlighter.getTargetArea() == HighlighterTargetArea.LINES_IN_RANGE; if (isLineHighlighter || highlighter.getStartOffset() < offset) { list1.add(highlighter); } if (isLineHighlighter || highlighter.getEndOffset() > offset || (highlighter.getEndOffset() == offset && (highlighter.isGreedyToRight()))) { list2.add(highlighter); } return true; }; editor.getFilteredDocumentMarkupModel().processRangeHighlightersOverlappingWith(Math.max(0, offset - 1), offset, processor); editor.getMarkupModel().processRangeHighlightersOverlappingWith(Math.max(0, offset - 1), offset, processor); updateAttributes(editor, attributes.get(0), list1); updateAttributes(editor, attributes.get(1), list2); }