From 0b95b1906899495029fdfff37f755591555a4f04 Mon Sep 17 00:00:00 2001 From: Dmitry Batkovich Date: Tue, 23 Aug 2016 17:09:20 +0300 Subject: [PATCH] null-literal argument: do not check nullable parameters with dfa + improve problem description text --- .../codeInspection/dataFlow/DataFlowInspectionBase.java | 2 +- .../codeInspection/dataFlow/NullParameterConstraintChecker.java | 1 + .../src/messages/InspectionsBundle.properties | 2 +- 3 files changed, 3 insertions(+), 2 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 24521a279148..7a5465c50058 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 @@ -151,7 +151,7 @@ public class DataFlowInspectionBase extends BaseJavaBatchLocalInspectionTool { for (PsiParameter parameter : NullParameterConstraintChecker.checkMethodParameters(method, isOnTheFly)) { final String name = parameter.getName(); holder.registerProblem(parameter.getNameIdentifier(), - InspectionsBundle.message("dataflow.method.fails.with.null.argument", name), + InspectionsBundle.message("dataflow.method.fails.with.null.argument"), ProblemHighlightType.GENERIC_ERROR_OR_WARNING, NullableStuffInspectionBase.getWrappedUiDependentQuickFix(this::createNavigateToNullParameterUsagesFix, parameter, isOnTheFly)); } diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/NullParameterConstraintChecker.java b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/NullParameterConstraintChecker.java index 296e5e2b33a4..7a0351e35125 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/NullParameterConstraintChecker.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/NullParameterConstraintChecker.java @@ -63,6 +63,7 @@ class NullParameterConstraintChecker extends DataFlowRunner { PsiParameter parameter = parameters[index]; if (!(parameter.getType() instanceof PsiPrimitiveType) && !NullableNotNullManager.isNotNull(parameter) && + !NullableNotNullManager.isNullable(parameter) && JavaNullMethodArgumentUtil.hasNullArgument(method, index)) { nullableParameters.add(parameter); } diff --git a/platform/platform-resources-en/src/messages/InspectionsBundle.properties b/platform/platform-resources-en/src/messages/InspectionsBundle.properties index bf713b8295c0..ca0f3b785cd1 100644 --- a/platform/platform-resources-en/src/messages/InspectionsBundle.properties +++ b/platform/platform-resources-en/src/messages/InspectionsBundle.properties @@ -92,7 +92,7 @@ dataflow.message.return.nullable.from.notnullable=Expression #ref m dataflow.message.unboxing=Unboxing of #ref #loc may produce java.lang.NullPointerException dataflow.message.unboxing.method.reference=Use of #ref #loc would need unboxing which may produce java.lang.NullPointerException dataflow.too.complex=Method #ref is too complex to analyze by data flow algorithm -dataflow.method.fails.with.null.argument=Method fails when parameter ''{0}'' is null +dataflow.method.fails.with.null.argument=Method will throw an exception when parameter is null #deprecated inspection.deprecated.display.name=Deprecated API usage