List<RangeHighlighter> () { List<FindResult> occurrences = mySearchResults.getOccurrences(); List<RangeHighlighter> newHighlighters = new ArrayList<>(occurrences.size()); for (FindResult range : occurrences) { if (range.getEndOffset() > mySearchResults.getEditor().getDocument().getTextLength()) continue; TextAttributes attributes = createAttributes(range); RangeHighlighter existingHighlighter = findExistingHighlighter(range.getStartOffset(), range.getEndOffset(), attributes); if (existingHighlighter == null) { RangeHighlighter highlighter = addHighlighter(range.getStartOffset(), range.getEndOffset(), attributes, myPresentation.getDefaultLayer()); if (highlighter != null) { highlighter.putUserData(SEARCH_MARKER, Boolean.TRUE); newHighlighters.add(highlighter); } } else { existingHighlighter.putUserData(MARKER_USED, Boolean.TRUE); } } return newHighlighters; }