disable null-argument checks in batch mode IDEA-CR-13940
authorDmitry Batkovich <dmitry.batkovich@jetbrains.com>
Tue, 20 Sep 2016 16:36:29 +0000 (19:36 +0300)
committerDmitry Batkovich <dmitry.batkovich@jetbrains.com>
Tue, 20 Sep 2016 16:36:29 +0000 (19:36 +0300)
java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/DataFlowInspectionBase.java
java/java-analysis-impl/src/com/intellij/codeInspection/nullable/NullableStuffInspectionBase.java

index 13f859edcbca5866e70a8ece4dcf30b21daf0ba7..4da776776b0ff5e54467ab482e80969c8e746f4f 100644 (file)
@@ -147,12 +147,12 @@ public class DataFlowInspectionBase extends BaseJavaBatchLocalInspectionTool {
   }
 
   private void analyzeNullLiteralMethodArguments(PsiMethod method, ProblemsHolder holder, boolean isOnTheFly) {
-    if (REPORT_NULLS_PASSED_TO_NOT_NULL_PARAMETER) {
-      for (PsiParameter parameter : NullParameterConstraintChecker.checkMethodParameters(method, isOnTheFly)) {
+    if (REPORT_NULLS_PASSED_TO_NOT_NULL_PARAMETER && isOnTheFly) {
+      for (PsiParameter parameter : NullParameterConstraintChecker.checkMethodParameters(method, true)) {
         holder.registerProblem(parameter.getNameIdentifier(),
                                InspectionsBundle.message("dataflow.method.fails.with.null.argument"),
                                ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
-                               NullableStuffInspectionBase.getWrappedUiDependentQuickFix(this::createNavigateToNullParameterUsagesFix, parameter, isOnTheFly));
+                               createNavigateToNullParameterUsagesFix(parameter));
       }
     }
   }
index dafd03e4bcea0be48f46cb423689c3da4edd183b..b6960f0a5e8e7c985b25e98888dfa5567689e23b 100644 (file)
@@ -43,7 +43,6 @@ import javax.swing.*;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Set;
-import java.util.function.Function;
 
 public class NullableStuffInspectionBase extends BaseJavaBatchLocalInspectionTool {
   // deprecated fields remain to minimize changes to users inspection profiles (which are often located in version control).
@@ -503,15 +502,14 @@ public class NullableStuffInspectionBase extends BaseJavaBatchLocalInspectionToo
                                                                 boolean isOnFly,
                                                                 int parameterIdx,
                                                                 PsiParameter parameter) {
-    if (REPORT_NULLS_PASSED_TO_NOT_NULL_PARAMETER && isNotNullNotInferred(parameter, false, false)) {
+    if (REPORT_NULLS_PASSED_TO_NOT_NULL_PARAMETER && isOnFly && isNotNullNotInferred(parameter, false, false)) {
       PsiAnnotation notNullAnnotation = nullableManager.getNotNullAnnotation(parameter, false);
       if (JavaNullMethodArgumentUtil.hasNullArgument(method, parameterIdx)) {
-        LocalQuickFix[] fixes = getWrappedUiDependentQuickFix(this::createNavigateToNullParameterUsagesFix, parameter, isOnFly);
         boolean physical = PsiTreeUtil.isAncestor(parameter, notNullAnnotation, true);
         holder.registerProblem(physical ? notNullAnnotation : parameter.getNameIdentifier(),
                                InspectionsBundle.message("inspection.nullable.problems.NotNull.parameter.receives.null.literal", getPresentableAnnoName(parameter)),
                                ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
-                               fixes);
+                               createNavigateToNullParameterUsagesFix(parameter));
       }
     }
   }
@@ -596,13 +594,6 @@ public class NullableStuffInspectionBase extends BaseJavaBatchLocalInspectionToo
     }
   }
 
-  @NotNull
-  public static LocalQuickFix[] getWrappedUiDependentQuickFix(Function<PsiParameter, LocalQuickFix> fixSupplier, PsiParameter parameter, boolean isOnTheFly) {
-    if (!isOnTheFly) return LocalQuickFix.EMPTY_ARRAY;
-    final LocalQuickFix fix = fixSupplier.apply(parameter);
-    return fix == null ? LocalQuickFix.EMPTY_ARRAY : new LocalQuickFix[]{fix};
-  }
-
   private static boolean isNotNullNotInferred(@NotNull PsiModifierListOwner owner, boolean checkBases, boolean skipExternal) {
     Project project = owner.getProject();
     NullableNotNullManager manager = NullableNotNullManager.getInstance(project);