void (final EditorImpl editor, final TextAttributes attributes, final List<? extends RangeHighlighterEx> highlighters) { if (highlighters.size() > 1) { ContainerUtil.quickSort(highlighters, IterationState.createByLayerThenByAttributesComparator(editor.getColorsScheme())); } TextAttributes syntax = attributes; TextAttributes caretRow = editor.getCaretModel().getTextAttributes(); final int size = highlighters.size(); //noinspection ForLoopReplaceableByForEach for (int i = 0; i < size; i++) { RangeHighlighterEx highlighter = highlighters.get(i); if (highlighter.getTextAttributes(editor.getColorsScheme()) == TextAttributes.ERASE_MARKER) { syntax = null; } } final List<TextAttributes> cachedAttributes = new ArrayList<>(); //noinspection ForLoopReplaceableByForEach for (int i = 0; i < size; i++) { RangeHighlighterEx highlighter = highlighters.get(i); if (caretRow != null && highlighter.getLayer() < HighlighterLayer.CARET_ROW) { cachedAttributes.add(caretRow); caretRow = null; } if (syntax != null && highlighter.getLayer() < HighlighterLayer.SYNTAX) { cachedAttributes.add(syntax); syntax = null; } TextAttributes textAttributes = highlighter.getTextAttributes(editor.getColorsScheme()); if (textAttributes != null && textAttributes != TextAttributes.ERASE_MARKER) { cachedAttributes.add(textAttributes); } } if (caretRow != null) cachedAttributes.add(caretRow); if (syntax != null) cachedAttributes.add(syntax); Color foreground = null; Color background = null; Color effect = null; EffectType effectType = null; int fontType = 0; //noinspection ForLoopReplaceableByForEach, Duplicates for (int i = 0; i < cachedAttributes.size(); i++) { TextAttributes attrs = cachedAttributes.get(i); if (foreground == null) { foreground = attrs.getForegroundColor(); } if (background == null) { background = attrs.getBackgroundColor(); } if (fontType == Font.PLAIN) { fontType = attrs.getFontType(); } if (effect == null) { effect = attrs.getEffectColor(); effectType = attrs.getEffectType(); } } if (foreground == null) foreground = editor.getForegroundColor(); if (background == null) background = editor.getBackgroundColor(); if (effectType == null) effectType = EffectType.BOXED; TextAttributes defaultAttributes = editor.getColorsScheme().getAttributes(HighlighterColors.TEXT); if (fontType == Font.PLAIN) fontType = defaultAttributes == null ? Font.PLAIN : defaultAttributes.getFontType(); attributes.setAttributes(foreground, background, effect, null, effectType, fontType); }