boolean (@NotNull List<? extends PsiElement> elements1, @NotNull LongList ranges1, @NotNull List<? extends PsiElement> elements2, @NotNull LongList ranges2, HighlightVisitor @NotNull [] visitors, @NotNull List<HighlightInfo> insideResult, @NotNull List<? super HighlightInfo> outsideResult, boolean forceHighlightParents) { Set<PsiElement> skipParentsSet = new HashSet<>(); HighlightInfoHolder holder = createInfoHolder(getFile()); ((AnnotationSessionImpl)holder.getAnnotationSession()).setVR(myPriorityRange); int chunkSize = Math.max(1, (elements1.size()+elements2.size()) / 100); // one percent precision is enough boolean success = analyzeByVisitors(visitors, holder, 0, () -> { LongStack nestedRange = new LongStack(); Stack<List<HighlightInfo>> nestedInfos = new Stack<>(); try (var ignored = HIGHLIGHTING_PERFORMANCE_ASSERT.runPass()) { runVisitors(elements1, ranges1, chunkSize, skipParentsSet, holder, insideResult, outsideResult, forceHighlightParents, visitors, nestedRange, nestedInfos); } boolean priorityIntersectionHasElements = myPriorityRange.intersectsStrict(myRestrictRange); if ((!elements1.isEmpty() || !insideResult.isEmpty()) || priorityIntersectionHasElements) { // do not apply when there were no elements to highlight myHighlightInfoProcessor.highlightsInsideVisiblePartAreProduced(myHighlightingSession, getEditor(), insideResult, myPriorityRange, myRestrictRange, getId()); } runVisitors(elements2, ranges2, chunkSize, skipParentsSet, holder, insideResult, outsideResult, forceHighlightParents, visitors, nestedRange, nestedInfos); }); // there can be extra highlights generated in PostHighlightVisitor List<HighlightInfo> postInfos = new ArrayList<>(holder.size()); for (int j = 0; j < holder.size(); j++) { HighlightInfo info = holder.get(j); postInfos.add(info); insideResult.add(info); } myHighlightInfoProcessor.highlightsInsideVisiblePartAreProduced(myHighlightingSession, getEditor(), postInfos, getFile().getTextRange(), getFile().getTextRange(), POST_UPDATE_ALL); return success; }