boolean (Editor editor, List<RangeHighlighter> hl) { final Set<RangeHighlighter> set = new ReferenceOpenHashSet<>(editor.getMarkupModel().getAllHighlighters()); boolean hasHighlighter = false; for (Iterator<RangeHighlighter> iterator = hl.iterator(); iterator.hasNext();) { final RangeHighlighter h = iterator.next(); if (!h.isValid() || !set.contains(h)) { iterator.remove(); } else { hasHighlighter = true; } } return hasHighlighter; }