void (@NotNull ProgressIndicator progress) { boolean isWholeFileToolsPass = getId() == Pass.WHOLE_FILE_LOCAL_INSPECTIONS; HighlightInfoUpdater highlightInfoUpdater = new HighlightInfoUpdater(getFile(), (MarkupModelEx)DocumentMarkupModel.forDocument(getDocument(), myProject, true), isWholeFileToolsPass, myProfileWrapper); List<HighlightInfo> fileInfos = Collections.synchronizedList(new ArrayList<>()); List<? extends LocalInspectionToolWrapper> toolWrappers = getInspectionTools(myProfileWrapper); List<? extends InspectionRunner.InspectionContext> resultContexts; if (toolWrappers.isEmpty()) { resultContexts = List.of(); } else { BiConsumer<ProblemDescriptor, InspectionRunner.InspectionProblemHolder> applyIncrementallyCallback = (descriptor, holder) -> { InspectionProfile inspectionProfile = myProfileWrapper.getInspectionProfile(); PsiElement descriptorPsiElement = descriptor.getPsiElement(); HighlightDisplayKey key = HighlightDisplayKey.find(holder.myToolWrapper.getShortName()); if (LOG.isDebugEnabled()) { LOG.debug("applyIncrementallyCallback: toolId:" + holder.myToolWrapper.getShortName() + ": "+descriptor+"; psi:"+descriptorPsiElement+"; isEnabled:"+inspectionProfile.isToolEnabled(key, getFile())); } if (descriptorPsiElement != null) { createHighlightsForDescriptor(descriptor, descriptorPsiElement, holder.myToolWrapper, info -> { holder.toolInfos.add(info); // do not apply incrementally outside visible range if (myPriorityRange.contains(info) && myHighlightingSession.addInfoIncrementally(info, myRestrictRange, getId())) { highlightInfoUpdater.infoAddedIncrementally(info, holder.getFile()); } }); } }; Consumer<InspectionRunner.InspectionContext> contextFinishedCallback = context -> { InspectionRunner.InspectionProblemHolder holder = context.holder(); Collection<HighlightInfo> infos = holder.toolInfos; if (LOG.isDebugEnabled()) { LOG.debug("contextFinishedCallback: " + context.tool() + "; toolId:" + context.tool().getShortName() + "; "+infos+"; "+context.elements().size()+" elements"); } highlightInfoUpdater.updateInspectionResult(holder.myToolWrapper, myHighlightingSession, infos, holder.getFile(), myRestrictRange); fileInfos.addAll(infos); }; InspectionRunner runner = new InspectionRunner(getFile(), myRestrictRange, myPriorityRange, myInspectInjectedPsi, true, progress, myIgnoreSuppressed, myProfileWrapper, mySuppressedElements); resultContexts = runner.inspect(toolWrappers, myHighlightingSession.getMinimumSeverity(), true, applyIncrementallyCallback, contextFinishedCallback, wrapper -> !wrapper.getTool().isSuppressedFor(myFile)); myInfos = fileInfos; } Set<Pair<Object, PsiFile>> pairs = ContainerUtil.map2Set(resultContexts, c -> Pair.create(c.tool().getShortName(), c.psiFile())); highlightInfoUpdater.removeObsoleteTools(pairs, myHighlightingSession); highlightInfoUpdater.removeWarningsInsideErrors(myHighlightingSession); // must be the last }