mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 06:50:54 +07:00
[java-inspections] Report TYPE_USE nullability annotation on classes
GitOrigin-RevId: f5c6113ccd1738d72b0f58fe13a8352a043431c9
This commit is contained in:
committed by
intellij-monorepo-bot
parent
8f2fe94325
commit
676c19bc1f
@@ -265,6 +265,7 @@ inspection.nullable.problems.primitive.type.annotation=Primitive type members ca
|
||||
inspection.nullable.problems.receiver.annotation=Receiver parameter is inherently not-null
|
||||
inspection.nullable.problems.applied.to.package=Annotation on fully-qualified name must be placed before the last component
|
||||
inspection.nullable.problems.outer.type=Outer type is inherently not-null
|
||||
inspection.nullable.problems.at.class=Nullability annotation is not applicable to classes
|
||||
inspection.nullable.problems.at.constructor=Nullability annotation is not applicable to constructors
|
||||
inspection.nullable.problems.at.enum.constant=Nullability annotation is not applicable to enum constants
|
||||
inspection.nullable.problems.at.wildcard=Nullability annotation is not applicable to wildcard type
|
||||
|
||||
@@ -215,6 +215,9 @@ public class NullableStuffInspectionBase extends AbstractBaseJavaLocalInspection
|
||||
if (listOwner instanceof PsiMethod method && method.isConstructor()) {
|
||||
reportIncorrectLocation(holder, annotation, listOwner, "inspection.nullable.problems.at.constructor");
|
||||
}
|
||||
if (listOwner instanceof PsiClass && AnnotationTargetUtil.findAnnotationTarget(annotation, PsiAnnotation.TargetType.TYPE) == null) {
|
||||
reportIncorrectLocation(holder, annotation, listOwner, "inspection.nullable.problems.at.class");
|
||||
}
|
||||
if (listOwner instanceof PsiEnumConstant) {
|
||||
reportIncorrectLocation(holder, annotation, listOwner, "inspection.nullable.problems.at.enum.constant");
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
<warning descr="Nullability annotation is not applicable to classes">@NotNull</warning>
|
||||
public class DisableOnClass {
|
||||
}
|
||||
@@ -422,6 +422,10 @@ public class NullableStuffInspectionTest extends LightJavaCodeInsightFixtureTest
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testDisableOnClass() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testParameterUnderDefaultNotNull() {
|
||||
DataFlowInspectionTestCase.addJetBrainsNotNullByDefault(myFixture);
|
||||
doTest();
|
||||
|
||||
Reference in New Issue
Block a user