mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Java: recognize "NullAway.Init" suppression (IDEA-380187)
for "@NotNull field is not initialized" inspection GitOrigin-RevId: 45348b8b8bdce0e64cd099f24d31a226f94567d8
This commit is contained in:
committed by
intellij-monorepo-bot
parent
bde408ecdb
commit
b15baa5372
@@ -2038,7 +2038,7 @@
|
||||
<localInspection groupPathKey="group.path.names.probable.bugs" language="JAVA" shortName="NotNullFieldNotInitialized"
|
||||
bundle="messages.JavaBundle" key="inspection.notnull.field.not.initialized.display.name"
|
||||
groupKey="group.names.nullability.problems" groupBundle="messages.InspectionsBundle" enabledByDefault="true"
|
||||
level="WARNING"
|
||||
level="WARNING" alternativeId="NullAway.Init"
|
||||
implementationClass="com.intellij.codeInspection.nullable.NotNullFieldNotInitializedInspection"/>
|
||||
<localInspection groupPath="Java" language="JAVA" shortName="ParameterCanBeLocal" key="inspection.parameter.can.be.local.display.name"
|
||||
groupKey="group.names.class.structure" groupBundle="messages.InspectionsBundle" enabledByDefault="true"
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
import javax.annotation.*;
|
||||
|
||||
@NonnullByDefault
|
||||
class Test {
|
||||
@SuppressWarnings("NullAway.Init")
|
||||
Object member;
|
||||
|
||||
private void accessMember() {
|
||||
member = new Object();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Nonnull
|
||||
@javax.annotation.meta.TypeQualifierDefault(java.lang.annotation.ElementType.FIELD)
|
||||
@interface NonnullByDefault {}
|
||||
+5
-2
@@ -1,5 +1,4 @@
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.java.codeInspection;
|
||||
|
||||
import com.intellij.JavaTestUtil;
|
||||
@@ -22,6 +21,10 @@ public class NotNullFieldNotInitializedInspectionTest extends LightJavaCodeInsig
|
||||
DataFlowInspectionTestCase.setupTypeUseAnnotations("typeUse", myFixture);
|
||||
doTest();
|
||||
}
|
||||
public void testSuppressNullAwayInit() {
|
||||
DataFlowInspectionTest.addJavaxNullabilityAnnotations(myFixture);
|
||||
doTest();
|
||||
}
|
||||
public void testNotNullByDefaultFieldNotInitialized() {
|
||||
DataFlowInspectionTest.addJavaxNullabilityAnnotations(myFixture);
|
||||
doTest();
|
||||
|
||||
Reference in New Issue
Block a user