From 7413fddf5f84a4ceab0108421d26396de673ae2a Mon Sep 17 00:00:00 2001 From: "Anna.Kozlova" Date: Mon, 4 Dec 2017 11:39:32 +0100 Subject: [PATCH] assertion to ensure tools do not register INFORMATION level problems in batch such problems are intended to provide a quick fix only which should be treated as intention, thus should not be shown in batch mode --- .../intellij/codeInspection/ProblemHighlightType.java | 4 +++- .../codeInsight/daemon/impl/LocalInspectionsPass.java | 9 +++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/platform/analysis-api/src/com/intellij/codeInspection/ProblemHighlightType.java b/platform/analysis-api/src/com/intellij/codeInspection/ProblemHighlightType.java index f0ef543e06b2..ad6d0285cd23 100644 --- a/platform/analysis-api/src/com/intellij/codeInspection/ProblemHighlightType.java +++ b/platform/analysis-api/src/com/intellij/codeInspection/ProblemHighlightType.java @@ -41,7 +41,9 @@ public enum ProblemHighlightType { /** Enforces {@link com.intellij.codeHighlighting.HighlightDisplayLevel#WEAK_WARNING} severity level */ WEAK_WARNING, - /** Enforces {@link com.intellij.codeHighlighting.HighlightDisplayLevel#DO_NOT_SHOW} severity level */ + /** Enforces {@link com.intellij.codeHighlighting.HighlightDisplayLevel#DO_NOT_SHOW} severity level + * Please ensure that if used from inspection explicitly, corresponding problem is added in the onTheFly mode only + */ INFORMATION, /** JEP 277 enhanced deprecation */ 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 182fd9cd3c1a..2460990c9e08 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 @@ -134,12 +134,21 @@ public class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass @NotNull final List toolWrappers) { final ProgressIndicator progress = ProgressManager.getInstance().getProgressIndicator(); inspect(new ArrayList<>(toolWrappers), iManager, false, false, progress); + boolean isSingleToolRun = context.getCurrentProfile().getSingleTool() != null; addDescriptorsFromInjectedResults(iManager, context); List resultList = result.get(getFile()); if (resultList == null) return; + Set toolsWithInformationInBatch = new HashSet<>(); for (InspectionResult inspectionResult : resultList) { LocalInspectionToolWrapper toolWrapper = inspectionResult.tool; + final String shortName = toolWrapper.getShortName(); for (ProblemDescriptor descriptor : inspectionResult.foundProblems) { + if (!isSingleToolRun && + descriptor.getHighlightType() == ProblemHighlightType.INFORMATION && + toolsWithInformationInBatch.add(shortName)) { + LOG.error("Tool '" + shortName + "' registers INFORMATION level problem in batch mode, " + + "though warning or level is used in user's settings"); + } addDescriptors(toolWrapper, descriptor, context); } }