forbid 'static'/'default' in annotation types

This commit is contained in:
Anna Kozlova
2014-08-18 13:15:15 +04:00
parent 87a984538a
commit 81fc7616bf
3 changed files with 17 additions and 0 deletions

View File

@@ -889,6 +889,11 @@ public class HighlightUtil extends HighlightUtilBase {
PsiModifier.STRICTFP.equals(modifier) || PsiModifier.SYNCHRONIZED.equals(modifier)) {
isAllowed &= modifierOwnerParent instanceof PsiClass && !((PsiClass)modifierOwnerParent).isInterface();
}
if (containingClass != null && containingClass.isAnnotationType()) {
isAllowed &= !PsiModifier.STATIC.equals(modifier);
isAllowed &= !PsiModifier.DEFAULT.equals(modifier);
}
}
else if (modifierOwner instanceof PsiField) {
if (PsiModifier.PRIVATE.equals(modifier) || PsiModifier.PROTECTED.equals(modifier) || PsiModifier.TRANSIENT.equals(modifier) ||

View File

@@ -0,0 +1,9 @@
@interface Example {
public <error descr="Modifier 'static' not allowed here">static</error> String myMethod() {
return "";
}
public <error descr="Modifier 'default' not allowed here">default</error> String myMethod1() {
return "";
}
}

View File

@@ -43,6 +43,9 @@ public class Interface8MethodsHighlightingTest extends LightCodeInsightFixtureTe
public void testDefaultSupersInStaticContext() {
doTest(false, false);
}
public void testAnnotationTypeExtensionsNotSupported() {
doTest(false, false);
}
public void testSuperProtectedCalls() throws Exception {
myFixture.addClass("package p; public class Foo {" +