From 1a35d4b01ebc34a2e67f19bff10f10c9bd0cfbf7 Mon Sep 17 00:00:00 2001 From: Dmitry Batkovich Date: Tue, 20 Sep 2016 19:36:29 +0300 Subject: [PATCH] disable null-argument checks in batch mode IDEA-CR-13940 --- .../dataFlow/DataFlowInspectionBase.java | 6 +++--- .../nullable/NullableStuffInspectionBase.java | 13 ++----------- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/DataFlowInspectionBase.java b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/DataFlowInspectionBase.java index 13f859edcbca..4da776776b0f 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/DataFlowInspectionBase.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/DataFlowInspectionBase.java @@ -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)); } } } diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/nullable/NullableStuffInspectionBase.java b/java/java-analysis-impl/src/com/intellij/codeInspection/nullable/NullableStuffInspectionBase.java index dafd03e4bcea..b6960f0a5e8e 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/nullable/NullableStuffInspectionBase.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/nullable/NullableStuffInspectionBase.java @@ -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 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);