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
This commit is contained in:
Anna.Kozlova
2017-12-04 12:57:44 +01:00
parent 39954ad9a8
commit 7413fddf5f
2 changed files with 12 additions and 1 deletions
@@ -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 */
@@ -134,12 +134,21 @@ public class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass
@NotNull final List<LocalInspectionToolWrapper> 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<InspectionResult> resultList = result.get(getFile());
if (resultList == null) return;
Set<String> 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);
}
}