From 1d759e10e34ea33f9a2a05d2748e9fe635ab4ada Mon Sep 17 00:00:00 2001 From: "Anna.Kozlova" Date: Fri, 3 Nov 2017 11:54:28 +0100 Subject: [PATCH] tooltips for INFORMATION level: default change to 'no' (IDEA-181493) initially one who wanted to provide some fixes without highlighting should created ProblemDescriptor manually and disable tooltip explicitly; looks like it's too tedious to teach all inspection authors to do so and all existing usages were similar: disable if INFORMATION. Let's apply as default --- .../codeInspection/AnonymousCanBeLambdaInspection.java | 7 ++----- .../AnonymousCanBeMethodReferenceInspection.java | 9 +++------ .../codeInspection/OptionalIsPresentInspection.java | 9 +++------ .../java18api/Java8MapForEachInspection.java | 4 ++-- .../intellij/codeInspection/InspectionManagerBase.java | 6 +++--- 5 files changed, 13 insertions(+), 22 deletions(-) diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/AnonymousCanBeLambdaInspection.java b/java/java-analysis-impl/src/com/intellij/codeInspection/AnonymousCanBeLambdaInspection.java index 1984f25aad39..caffccb738d1 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/AnonymousCanBeLambdaInspection.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/AnonymousCanBeLambdaInspection.java @@ -93,11 +93,8 @@ public class AnonymousCanBeLambdaInspection extends AbstractBaseJavaLocalInspect type = ProblemHighlightType.INFORMATION; } } - ProblemDescriptorBase descriptor = new ProblemDescriptorBase(parent, parent, "Anonymous #ref #loc can be replaced with lambda", - new LocalQuickFix[]{new ReplaceWithLambdaFix()}, - type, false, rangeInElement, - type != ProblemHighlightType.INFORMATION, true); - holder.registerProblem(descriptor); + holder.registerProblem(parent, "Anonymous #ref #loc can be replaced with lambda", + type, rangeInElement, new ReplaceWithLambdaFix()); } } }; diff --git a/java/java-impl/src/com/intellij/codeInspection/AnonymousCanBeMethodReferenceInspection.java b/java/java-impl/src/com/intellij/codeInspection/AnonymousCanBeMethodReferenceInspection.java index 65a070ba6945..97d87c74f782 100644 --- a/java/java-impl/src/com/intellij/codeInspection/AnonymousCanBeMethodReferenceInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/AnonymousCanBeMethodReferenceInspection.java @@ -88,12 +88,9 @@ public class AnonymousCanBeMethodReferenceInspection extends AbstractBaseJavaLoc ProblemHighlightType type = methodReferenceCandidate.mySafeQualifier && methodReferenceCandidate.myConformsCodeStyle ? ProblemHighlightType.LIKE_UNUSED_SYMBOL : ProblemHighlightType.INFORMATION; - ProblemDescriptorBase descriptor = new ProblemDescriptorBase(parent, parent, - "Anonymous #ref #loc can be replaced with method reference", - new LocalQuickFix[]{new ReplaceWithMethodRefFix()}, - type, false, rangeInElement, - type != ProblemHighlightType.INFORMATION, true); - holder.registerProblem(descriptor); + holder.registerProblem(parent, + "Anonymous #ref #loc can be replaced with method reference", + type, rangeInElement, new ReplaceWithMethodRefFix()); } } } diff --git a/java/java-impl/src/com/intellij/codeInspection/OptionalIsPresentInspection.java b/java/java-impl/src/com/intellij/codeInspection/OptionalIsPresentInspection.java index 7f196544f4bc..6385c4a75a8b 100644 --- a/java/java-impl/src/com/intellij/codeInspection/OptionalIsPresentInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/OptionalIsPresentInspection.java @@ -47,12 +47,9 @@ public class OptionalIsPresentInspection extends AbstractBaseJavaLocalInspection void registerProblem(ProblemsHolder holder, PsiExpression condition, OptionalIsPresentCase scenario) { if(this != NONE) { - holder.registerProblem(holder.getManager().createProblemDescriptor(condition, - "Can be replaced with single expression in functional style", - this != INFO, - this == INFO ? ProblemHighlightType.INFORMATION : ProblemHighlightType.GENERIC_ERROR_OR_WARNING, - true, - new OptionalIsPresentFix(scenario))); + holder.registerProblem(condition, "Can be replaced with single expression in functional style", + this == INFO ? ProblemHighlightType.INFORMATION : ProblemHighlightType.GENERIC_ERROR_OR_WARNING, + new OptionalIsPresentFix(scenario)); } } } diff --git a/java/java-impl/src/com/intellij/codeInspection/java18api/Java8MapForEachInspection.java b/java/java-impl/src/com/intellij/codeInspection/java18api/Java8MapForEachInspection.java index 841235ee07da..a520bf1890b8 100644 --- a/java/java-impl/src/com/intellij/codeInspection/java18api/Java8MapForEachInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/java18api/Java8MapForEachInspection.java @@ -100,8 +100,8 @@ public class Java8MapForEachInspection extends AbstractBaseJavaLocalInspectionTo else { range = new TextRange(0, firstChild.getTextLength()); } - holder.registerProblem(new ProblemDescriptorBase(firstChild, firstChild, InspectionsBundle.message("inspection.map.foreach.message"), - new LocalQuickFix[]{new ReplaceWithMapForEachFix()}, type, false, range, type != ProblemHighlightType.INFORMATION, holder.isOnTheFly())); + holder.registerProblem(loop.getFirstChild(), InspectionsBundle.message("inspection.map.foreach.message"), + type, range, new ReplaceWithMapForEachFix()); } } }; diff --git a/platform/analysis-impl/src/com/intellij/codeInspection/InspectionManagerBase.java b/platform/analysis-impl/src/com/intellij/codeInspection/InspectionManagerBase.java index 291db3525e2d..921670976f3f 100644 --- a/platform/analysis-impl/src/com/intellij/codeInspection/InspectionManagerBase.java +++ b/platform/analysis-impl/src/com/intellij/codeInspection/InspectionManagerBase.java @@ -80,7 +80,7 @@ public abstract class InspectionManagerBase extends InspectionManager { @NotNull ProblemHighlightType highlightType, boolean onTheFly, boolean isAfterEndOfLine) { - return new ProblemDescriptorBase(psiElement, psiElement, descriptionTemplate, fixes, highlightType, isAfterEndOfLine, null, true, onTheFly); + return new ProblemDescriptorBase(psiElement, psiElement, descriptionTemplate, fixes, highlightType, isAfterEndOfLine, null, highlightType != ProblemHighlightType.INFORMATION, onTheFly); } @Override @@ -91,7 +91,7 @@ public abstract class InspectionManagerBase extends InspectionManager { @NotNull ProblemHighlightType highlightType, boolean onTheFly, LocalQuickFix... fixes) { - return new ProblemDescriptorBase(startElement, endElement, descriptionTemplate, fixes, highlightType, false, null, true, onTheFly); + return new ProblemDescriptorBase(startElement, endElement, descriptionTemplate, fixes, highlightType, false, null, highlightType != ProblemHighlightType.INFORMATION, onTheFly); } @NotNull @@ -102,7 +102,7 @@ public abstract class InspectionManagerBase extends InspectionManager { @NotNull final ProblemHighlightType highlightType, boolean onTheFly, final LocalQuickFix... fixes) { - return new ProblemDescriptorBase(psiElement, psiElement, descriptionTemplate, fixes, highlightType, false, rangeInElement, true, onTheFly); + return new ProblemDescriptorBase(psiElement, psiElement, descriptionTemplate, fixes, highlightType, false, rangeInElement, highlightType != ProblemHighlightType.INFORMATION, onTheFly); } @NotNull