From 60f631689ccfccb34fc0283c878d0a37cb56c260 Mon Sep 17 00:00:00 2001 From: Tagir Valeev Date: Tue, 15 Apr 2025 15:48:36 +0200 Subject: [PATCH] [java-inspections] Internationalize inspection message for IDEA-370683 GitOrigin-RevId: 811c4c00965ea6efdc68204ae45f88be321ff689 --- .../resources/messages/JavaAnalysisBundle.properties | 1 + .../nullable/NullableStuffInspectionBase.java | 3 ++- .../nullableProblems/IncompatibleConstructors.java | 8 ++++---- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/java/java-analysis-api/resources/messages/JavaAnalysisBundle.properties b/java/java-analysis-api/resources/messages/JavaAnalysisBundle.properties index c4efcde17205..ced422a7d541 100644 --- a/java/java-analysis-api/resources/messages/JavaAnalysisBundle.properties +++ b/java/java-analysis-api/resources/messages/JavaAnalysisBundle.properties @@ -250,6 +250,7 @@ inspection.nullable.problems.at.wildcard=Nullability annotation is not applicabl inspection.nullable.problems.at.local.variable=Nullability annotation is not applicable to local variables inspection.nullable.problems.at.type.parameter=Nullability annotation is not applicable to type parameters inspection.nullable.problems.at.reference.list=Nullability annotation is not applicable to extends/implements clause +inspection.nullable.problems.constructor.not.compatible.non.null.type.argument=Constructor is not compatible with a non-null type argument inspection.objects.equals.can.be.simplified.display.name='Objects.equals()' can be replaced with 'equals()' inspection.redundant.cast.problem.descriptor=Casting {0} to #ref #loc is redundant inspection.redundant.cast.methodref.descriptor=Cast is redundant 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 cb7037c37a42..6ed218f5c493 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 @@ -153,7 +153,8 @@ public class NullableStuffInspectionBase extends AbstractBaseJavaLocalInspection typeElement.acceptsAnnotations()) { fix = new AddTypeAnnotationFix(typeElement, manager.getDefaultNullable(), notNulls); } - holder.problem(expression, "Constructor is not compatible with non-null type argument") + holder.problem(expression, + JavaAnalysisBundle.message("inspection.nullable.problems.constructor.not.compatible.non.null.type.argument")) .maybeFix(fix) .register(); } diff --git a/java/java-tests/testData/inspection/nullableProblems/IncompatibleConstructors.java b/java/java-tests/testData/inspection/nullableProblems/IncompatibleConstructors.java index 30f0ef860ade..3f3145b68006 100644 --- a/java/java-tests/testData/inspection/nullableProblems/IncompatibleConstructors.java +++ b/java/java-tests/testData/inspection/nullableProblems/IncompatibleConstructors.java @@ -11,12 +11,12 @@ import java.util.stream.Collectors; @NullMarked class Main { public static void main(String[] args) { - AtomicReference ref = new AtomicReference<>(); - AtomicReference ref1 = new AtomicReference(); + AtomicReference ref = new AtomicReference<>(); + AtomicReference ref1 = new AtomicReference(); AtomicReference ref2 = new AtomicReference<>(null); AtomicReference ref3 = new AtomicReference<>(""); - ThreadLocal tl = new ThreadLocal<>(); + ThreadLocal tl = new ThreadLocal<>(); ThreadLocal tl2 = new ThreadLocal<>() { @Override protected String initialValue() { @@ -25,7 +25,7 @@ class Main { }; ThreadLocal tl3 = ThreadLocal.withInitial(() -> null); - AtomicReferenceArray arr = new AtomicReferenceArray<>(10); + AtomicReferenceArray arr = new AtomicReferenceArray<>(10); AtomicReferenceArray arr2 = new AtomicReferenceArray<>(new String[10]); // technically wrong and should be highlighted, as array contains nulls @Nullable String[] data = new String[10]; AtomicReferenceArray arr3 = new AtomicReferenceArray<>(data); // technically wrong and should be highlighted, as array contains nulls