mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java-highlighting] IDEA-289314 Missing highlighting for nested type annotations on static types
- annotations are checked recursively GitOrigin-RevId: a8343f6bbfbf2dd39b29dad8ce1e989e71a0e549
This commit is contained in:
committed by
intellij-monorepo-bot
parent
8adeaf3193
commit
87dc3f3fbf
+7
-1
@@ -511,13 +511,19 @@ public final class AnnotationsHighlightUtil {
|
||||
}
|
||||
|
||||
PsiElement parent = ref.getParent();
|
||||
if (parent instanceof PsiJavaCodeReferenceElement) {
|
||||
while (parent instanceof PsiJavaCodeReferenceElement) {
|
||||
PsiElement qualified = ((PsiJavaCodeReferenceElement)parent).resolve();
|
||||
if (qualified instanceof PsiMember && ((PsiMember)qualified).hasModifierProperty(PsiModifier.STATIC)) {
|
||||
return createAnnotationError(annotation,
|
||||
JavaErrorBundle.message("annotation.not.allowed.static"),
|
||||
new MoveAnnotationOnStaticMemberQualifyingTypeFix(annotation).asIntention());
|
||||
}
|
||||
if (qualified instanceof PsiClass) {
|
||||
parent = parent.getParent();
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
+17
@@ -133,4 +133,21 @@ class Outer {
|
||||
IntFunction<Super> f = Outer.<error descr="Annotations are not allowed here">@TA</error> This.super::getField;
|
||||
}
|
||||
}
|
||||
|
||||
void testAnnotation() {
|
||||
<error descr="Static member qualifying type may not be annotated">@TA</error> T.Y.U.I.O o2;
|
||||
T.<error descr="Static member qualifying type may not be annotated">@TA</error> Y.U.I.O o;
|
||||
T.Y.<error descr="Static member qualifying type may not be annotated">@TA</error> U.I.O o3;
|
||||
T.Y.U.<error descr="Static member qualifying type may not be annotated">@TA</error> I.O o4;
|
||||
}
|
||||
|
||||
public class T {
|
||||
public static class Y {
|
||||
public class U {
|
||||
public class I {
|
||||
public static class O { }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user