mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-13 09:19:13 +07:00
[java] type annotation highlighting on type parameters (IDEA-174317)
This commit is contained in:
+9
-10
@@ -376,9 +376,10 @@ public class AnnotationsHighlightUtil {
|
||||
HighlightInfo info = checkReferenceTarget(annotation, ref);
|
||||
if (info != null) return info;
|
||||
}
|
||||
else if (owner instanceof PsiModifierList) {
|
||||
PsiElement nextElement = PsiTreeUtil.skipSiblingsForward((PsiModifierList)owner,
|
||||
PsiComment.class, PsiWhiteSpace.class, PsiTypeParameterList.class);
|
||||
else if (owner instanceof PsiModifierList || owner instanceof PsiTypeElement) {
|
||||
PsiElement nextElement = owner instanceof PsiTypeElement
|
||||
? (PsiTypeElement)owner
|
||||
: PsiTreeUtil.skipSiblingsForward((PsiModifierList)owner, PsiComment.class, PsiWhiteSpace.class, PsiTypeParameterList.class);
|
||||
if (nextElement instanceof PsiTypeElement) {
|
||||
PsiTypeElement typeElement = (PsiTypeElement)nextElement;
|
||||
PsiType type = typeElement.getType();
|
||||
@@ -391,13 +392,11 @@ public class AnnotationsHighlightUtil {
|
||||
HighlightInfo info = checkReferenceTarget(annotation, ref);
|
||||
if (info != null) return info;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (owner instanceof PsiTypeElement) {
|
||||
PsiElement context = PsiTreeUtil.skipParentsOfType((PsiTypeElement)owner, PsiTypeElement.class);
|
||||
if (context instanceof PsiClassObjectAccessExpression) {
|
||||
String message = JavaErrorMessages.message("annotation.not.allowed.class");
|
||||
return annotationError(annotation, message);
|
||||
PsiElement context = PsiTreeUtil.skipParentsOfType(typeElement, PsiTypeElement.class);
|
||||
if (context instanceof PsiClassObjectAccessExpression) {
|
||||
String message = JavaErrorMessages.message("annotation.not.allowed.class");
|
||||
return annotationError(annotation, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+4
-1
@@ -51,7 +51,8 @@ class Outer {
|
||||
@TA StaticInner v1;
|
||||
<error descr="Static member qualifying type may not be annotated">@TA</error> StaticMiddle.@TA StaticInner v2;
|
||||
<error descr="Static member qualifying type may not be annotated">@TA</error> Outer.<error descr="Static member qualifying type may not be annotated">@TA</error> StaticMiddle.@TA StaticInner v3;
|
||||
List<@TA Outer.<error descr="Static member qualifying type may not be annotated">@TA</error> StaticMiddle.@TA StaticInner> l;
|
||||
List<Outer.<error descr="Static member qualifying type may not be annotated">@TA</error> StaticMiddle.@TA StaticInner> l1;
|
||||
List<<error descr="Static member qualifying type may not be annotated">@TA</error> Outer.StaticMiddle.@TA StaticInner> l2;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -67,7 +68,9 @@ class Outer {
|
||||
@A Map.@TA Entry e1;
|
||||
@A <error descr="Static member qualifying type may not be annotated">@TA</error> Map.@TA Entry e2;
|
||||
@A java.<error descr="Annotation not applicable to this kind of reference">@TA</error> util.Map.@TA Entry e3;
|
||||
@A <error descr="Annotation not applicable to this kind of reference">@TA</error> java.util.Map.@TA Entry e4;
|
||||
@A List<java.<error descr="Annotation not applicable to this kind of reference">@TA</error> lang.@TA String> l1;
|
||||
@A List<<error descr="Annotation not applicable to this kind of reference">@TA</error> java.lang.String> l2;
|
||||
|
||||
Object obj = "str";
|
||||
@TA String str = (@TA String)obj;
|
||||
|
||||
Reference in New Issue
Block a user