List<HighlightInfo> (@NotNull TextRange range, @NotNull List<? extends HighlightInfo> newInfos, @NotNull List<? extends HighlightInfo> oldInfos, @NotNull MarkupModelEx markup, @NotNull HighlightingSession session) { ApplicationManager.getApplication().assertIsNonDispatchThread(); ApplicationManager.getApplication().assertReadAccessAllowed(); PsiFile psiFile = session.getPsiFile(); Project project = session.getProject(); SeverityRegistrar severityRegistrar = SeverityRegistrar.getSeverityRegistrar(project); HighlightersRecycler toReuse = new HighlightersRecycler(); Document document = session.getDocument(); Long2ObjectMap<RangeMarker> range2markerCache = new Long2ObjectOpenHashMap<>(10); boolean[] changed = {false}; List<HighlightInfo> result = new ArrayList<>(oldInfos.size()); try { for (HighlightInfo oldInfo : oldInfos) { RangeHighlighterEx highlighter = oldInfo.getHighlighter(); if (highlighter != null && range.contains(highlighter)) { toReuse.recycleHighlighter(highlighter); } else { result.add(oldInfo); } } List<HighlightInfo> filteredNewInfos = UpdateHighlightersUtil.HighlightInfoPostFilters.applyPostFilter(project, newInfos); ContainerUtil.quickSort(filteredNewInfos, UpdateHighlightersUtil.BY_ACTUAL_START_OFFSET_NO_DUPS); SweepProcessor.Generator<HighlightInfo> generator = processor -> ContainerUtil.process(filteredNewInfos, processor); List<HighlightInfo> infosToCreateHighlightersFor = new ArrayList<>(filteredNewInfos.size()); SweepProcessor.sweep(generator, (__, info, atStart, overlappingIntervals) -> { if (!atStart) { return true; } if (range.contains(info) && !UpdateHighlightersUtil.isWarningCoveredByError(info, severityRegistrar, overlappingIntervals)) { // have to create RangeHighlighter later, to avoid exposing them to the markup model immediately, // thus messing the HighlightInfo.getStartOffset() leading to "sweep generator supplied infos in a wrong order" exception infosToCreateHighlightersFor.add(info); changed[0] = true; } return true; }); for (HighlightInfo info : infosToCreateHighlightersFor) { if (info.isFileLevelAnnotation()) { //session. RangeHighlighterEx salvagedHighlighter = toReuse.pickupHighlighterFromGarbageBin(0, psiFile.getTextLength(), -409423948); session.addFileLevelHighlight(info, salvagedHighlighter); } else { BackgroundUpdateHighlightersUtil.createOrReuseHighlighterFor(info, session.getColorsScheme(), document, Pass.LOCAL_INSPECTIONS, psiFile, markup, toReuse, range2markerCache, severityRegistrar); } result.add(info); } changed[0] |= UpdateHighlightersUtil.incinerateObsoleteHighlighters(toReuse, session); } finally { toReuse.releaseHighlighters(); } if (changed[0]) { UpdateHighlightersUtil.clearWhiteSpaceOptimizationFlag(document); } return result; }