[java] validates container annotation "concreteness" (IDEA-201354)

This commit is contained in:
Roman Shevchenko
2018-11-09 22:08:41 +01:00
parent 0c3c597fb8
commit 35ca6e9efd
3 changed files with 10 additions and 0 deletions

View File

@@ -623,6 +623,12 @@ public class AnnotationsHighlightUtil {
}
}
for (PsiMethod method : container.getMethods()) {
if (method instanceof PsiAnnotationMethod && !"value".equals(method.getName()) && ((PsiAnnotationMethod)method).getDefaultValue() == null) {
return JavaErrorMessages.message("annotation.container.abstract", container.getQualifiedName(), method.getName());
}
}
return null;
}

View File

@@ -24,6 +24,7 @@ annotation.container.no.value=Invalid container annotation ''{0}'': no ''value''
annotation.container.bad.type=Invalid container annotation ''{0}'': ''value'' method should have type ''{1}''
annotation.container.low.retention=Container annotation ''{0}'' has shorter retention (''{1}'') than the contained annotation
annotation.container.wide.target=Target of container annotation ''{0}'' is not a subset of target of this annotation
annotation.container.abstract=Container annotation ''{0}'' does not have a default value for ''{1}''
annotation.duplicate.explained=Duplicate annotation. {0}
annotation.non.repeatable=The declaration of ''{0}'' does not have a valid java.lang.annotation.Repeatable annotation
annotation.container.wrong.place=Container annotation ''{0}'' must not be present at the same time as the element it contains

View File

@@ -53,3 +53,6 @@ class C8 {
<error descr="Container annotation '@AA8' is not applicable to field">@A8</error> <error descr="Container annotation '@AA8' is not applicable to field">@A8</error> int f2;
@A8 @A8 void m() { }
}
@interface AA9 { A9[] value(); int i(); }
@Repeatable(<error descr="Container annotation 'AA9' does not have a default value for 'i'">AA9.class</error>) @interface A9 { }