mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
invalid annotation type detection based on type element (IDEA-142884)
This commit is contained in:
+3
-4
@@ -321,12 +321,11 @@ public class AnnotationsHighlightUtil {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
static HighlightInfo checkValidAnnotationType(final PsiTypeElement typeElement) {
|
||||
PsiType type = typeElement.getType();
|
||||
if (type.accept(AnnotationReturnTypeVisitor.INSTANCE).booleanValue()) {
|
||||
static HighlightInfo checkValidAnnotationType(PsiType type, final PsiTypeElement typeElement) {
|
||||
if (type != null && type.accept(AnnotationReturnTypeVisitor.INSTANCE).booleanValue()) {
|
||||
return null;
|
||||
}
|
||||
String description = JavaErrorMessages.message("annotation.invalid.annotation.member.type");
|
||||
String description = JavaErrorMessages.message("annotation.invalid.annotation.member.type", type != null ? type.getPresentableText() : type);
|
||||
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(typeElement).descriptionAndTooltip(description).create();
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -276,7 +276,7 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
|
||||
myHolder.add(AnnotationsHighlightUtil.checkMemberValueType(value, returnType));
|
||||
}
|
||||
|
||||
myHolder.add(AnnotationsHighlightUtil.checkValidAnnotationType(method.getReturnTypeElement()));
|
||||
myHolder.add(AnnotationsHighlightUtil.checkValidAnnotationType(method.getReturnType(), method.getReturnTypeElement()));
|
||||
final PsiClass aClass = method.getContainingClass();
|
||||
myHolder.add(AnnotationsHighlightUtil.checkCyclicMemberType(method.getReturnTypeElement(), aClass));
|
||||
myHolder.add(AnnotationsHighlightUtil.checkClashesWithSuperMethods(method));
|
||||
|
||||
@@ -11,7 +11,7 @@ annotation.not.applicable=''@{0}'' not applicable to {1}
|
||||
annotation.non.constant.attribute.value=Attribute value must be constant
|
||||
annotation.non.class.literal.attribute.value=Attribute value must be a class literal
|
||||
annotation.non.enum.constant.attribute.value=Attribute value must be an enum constant
|
||||
annotation.invalid.annotation.member.type=Invalid type for annotation member
|
||||
annotation.invalid.annotation.member.type=Invalid type ''{0}'' for annotation member
|
||||
annotation.cyclic.element.type=Cyclic annotation element type
|
||||
annotation.annotation.type.expected=Annotation type expected
|
||||
annotation.members.may.not.have.throws.list=@interface members may not have throws list
|
||||
|
||||
+2
-2
@@ -3,7 +3,7 @@
|
||||
Class <error descr="@interface member clashes with 'annotationType()' in java.lang.annotation.Annotation">annotationType</error>();
|
||||
int value();
|
||||
boolean equals();
|
||||
<error descr="Invalid type for annotation member">void</error> <error descr="@interface member clashes with 'finalize()' in java.lang.Object">finalize</error>();
|
||||
<error descr="Invalid type for annotation member">void</error> registerNatives();
|
||||
<error descr="Invalid type 'void' for annotation member">void</error> <error descr="@interface member clashes with 'finalize()' in java.lang.Object">finalize</error>();
|
||||
<error descr="Invalid type 'void' for annotation member">void</error> registerNatives();
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -1,8 +1,9 @@
|
||||
class Clazz {}
|
||||
|
||||
@interface Ann {
|
||||
<error descr="Invalid type for annotation member">Clazz</error> i ();
|
||||
<error descr="Invalid type 'Clazz' for annotation member">Clazz</error> i ();
|
||||
<error descr="Cyclic annotation element type">Ann</error> j ();
|
||||
|
||||
<error descr="Invalid type for annotation member">void</error> f();
|
||||
<error descr="Invalid type 'void' for annotation member">void</error> f();
|
||||
<error descr="Invalid type 'int[][]' for annotation member">int[]</error> intDblArray()[];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user