diff --git a/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfoUpdaterImpl.java b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfoUpdaterImpl.java index 5f604f286e1c..82e4ff45f44f 100644 --- a/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfoUpdaterImpl.java +++ b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfoUpdaterImpl.java @@ -536,7 +536,7 @@ public final class HighlightInfoUpdaterImpl extends HighlightInfoUpdater impleme recycler.recycleHighlighter(visitedPsiElement, oldInfo); } } - List newInfosToStore = assignRangeHighlighters(newInfos, session, psiFile, hostDocument, invalidElementRecycler, recycler, data); + List newInfosToStore = assignRangeHighlighters(newInfos, toolId, session, psiFile, hostDocument, invalidElementRecycler, recycler, data); ToolHighlights notNullToolHighlights = toolHighlights == null ? data.computeIfAbsent(toolId, __ -> new ToolHighlights()) : toolHighlights; if (newInfosToStore.isEmpty()) { @@ -1201,7 +1201,7 @@ public final class HighlightInfoUpdaterImpl extends HighlightInfoUpdater impleme * could be reentrant, be careful to avoid leaking/blinking RHs */ private static @NotNull @Unmodifiable List assignRangeHighlighters(@NotNull List newInfos, - @NotNull HighlightingSession session, + @NotNull Object toolId, @NotNull HighlightingSession session, @NotNull PsiFile psiFile, @NotNull Document hostDocument, @NotNull ManagedHighlighterRecycler invalidElementRecycler, @@ -1219,8 +1219,7 @@ public final class HighlightInfoUpdaterImpl extends HighlightInfoUpdater impleme //noinspection ForLoopReplaceableByForEach for (int i = 0; i < sorted.size(); i++) { HighlightInfo newInfo = sorted.get(i); - //todo fails because of ProblemDescriptorWithReporterName - //assert toolId.equals(newInfo.toolId) : newInfo + "; toolId=" + toolId + "(" + toolId.getClass() + ")"; + assert toolId.equals(newInfo.toolId) : "HighlightInfo generated by "+toolId + "(" + toolId.getClass() + ") must have consistent toolId, but got:"+ newInfo; boolean isFileLevel = newInfo.isFileLevelAnnotation(); long finalInfoRange = isFileLevel ? TextRangeScalarUtil.toScalarRange(0, psiFile.getTextLength()) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LocalInspectionsPass.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LocalInspectionsPass.java index d5f6eadc711e..80d5a9f84d0b 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LocalInspectionsPass.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LocalInspectionsPass.java @@ -250,28 +250,29 @@ final class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass private void createHighlightsForDescriptor(@NotNull ProblemDescriptor descriptor, @NotNull PsiElement psiElement, - @NotNull LocalInspectionToolWrapper tool, + @NotNull LocalInspectionToolWrapper toolWrapper, @NotNull Consumer infoProcessor) { + String originalShortName = toolWrapper.getShortName(); ApplicationManager.getApplication().assertIsNonDispatchThread(); if (descriptor instanceof ProblemDescriptorWithReporterName name) { String reportingToolName = name.getReportingToolShortName(); - tool = (LocalInspectionToolWrapper)myProfileWrapper.getInspectionTool(reportingToolName, psiElement); + toolWrapper = (LocalInspectionToolWrapper)myProfileWrapper.getInspectionTool(reportingToolName, psiElement); } - if (myIgnoreSuppressed && tool.getTool().isSuppressedFor(psiElement)) { - registerSuppressedElements(psiElement, tool.getID(), tool.getAlternativeID(), mySuppressedElements); + if (myIgnoreSuppressed && toolWrapper.getTool().isSuppressedFor(psiElement)) { + registerSuppressedElements(psiElement, toolWrapper.getID(), toolWrapper.getAlternativeID(), mySuppressedElements); return; } PsiFile psiFile = psiElement.getContainingFile(); - HighlightDisplayKey displayKey = tool.getDisplayKey(); + HighlightDisplayKey displayKey = toolWrapper.getDisplayKey(); if (displayKey == null) { - LOG.error("getDisplayKey() is null for " + tool + " (" + tool.getTool() + " ; " + tool.getTool().getClass() + ")"); + LOG.error("getDisplayKey() is null for " + toolWrapper + " (" + toolWrapper.getTool() + " ; " + toolWrapper.getTool().getClass() + ")"); return; } HighlightSeverity severity = myProfileWrapper.getErrorLevel(displayKey, psiFile).getSeverity(); - createHighlightsForDescriptor(emptyActionRegistered, psiFile, tool, severity, descriptor, psiElement, infoProcessor); + createHighlightsForDescriptor(emptyActionRegistered, psiFile, toolWrapper, originalShortName, severity, descriptor, psiElement, infoProcessor); } @Override @@ -282,6 +283,7 @@ final class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass private void createHighlightsForDescriptor(@NotNull Set> emptyActionRegistered, @NotNull PsiFile psiFile, @NotNull LocalInspectionToolWrapper toolWrapper, + @NotNull String originalShortName, @NotNull HighlightSeverity severity, @NotNull ProblemDescriptor descriptor, @NotNull PsiElement element, @@ -335,7 +337,7 @@ final class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass if (info == null || !UpdateHighlightersUtil.HighlightInfoPostFilters.accept(myProject, info)) { return; } - info.setToolId(toolWrapper.getShortName()); + info.setToolId(originalShortName); // toolId must be consistent with the tool which actually ran it info.setGroup(HighlightInfoUpdaterImpl.MANAGED_HIGHLIGHT_INFO_GROUP); if (isInInjected) { Document documentRange = documentManager.getDocument(psiFile);