IDEA-117391 (annotation highlighting fixed)

This commit is contained in:
Roman Shevchenko
2013-12-02 19:04:03 +01:00
parent 9553e5a06c
commit 393d831d3a
3 changed files with 13 additions and 5 deletions

View File

@@ -292,11 +292,14 @@ public class AnnotationsHighlightUtil {
private static final ElementPattern<PsiElement> ANY_ANNOTATION_ALLOWED = psiElement().andOr(
psiElement().withParent(PsiNameValuePair.class),
psiElement().withParents(PsiArrayInitializerMemberValue.class, PsiNameValuePair.class),
psiElement().withParents(PsiArrayInitializerMemberValue.class, PsiAnnotationMethod.class),
psiElement().withParent(PsiAnnotationMethod.class).afterLeaf(PsiKeyword.DEFAULT)
);
@Nullable
public static HighlightInfo checkApplicability(@NotNull PsiAnnotation annotation, @NotNull LanguageLevel languageLevel,@NotNull PsiFile containingFile) {
public static HighlightInfo checkApplicability(@NotNull PsiAnnotation annotation,
@NotNull LanguageLevel languageLevel,
@NotNull PsiFile containingFile) {
if (ANY_ANNOTATION_ALLOWED.accepts(annotation)) {
return null;
}

View File

@@ -29,7 +29,6 @@ import com.intellij.openapi.project.IndexNotReadyException;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.projectRoots.JavaSdkVersion;
import com.intellij.openapi.projectRoots.JavaVersionService;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.TextRange;
import com.intellij.pom.java.LanguageLevel;
@@ -202,7 +201,7 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
public void visitAnnotation(PsiAnnotation annotation) {
super.visitAnnotation(annotation);
if (!myHolder.hasErrorResults()) myHolder.add(HighlightUtil.checkAnnotationFeature(annotation, myLanguageLevel, myFile));
if (!myHolder.hasErrorResults()) myHolder.add(AnnotationsHighlightUtil.checkApplicability(annotation, myLanguageLevel,myFile));
if (!myHolder.hasErrorResults()) myHolder.add(AnnotationsHighlightUtil.checkApplicability(annotation, myLanguageLevel, myFile));
if (!myHolder.hasErrorResults()) myHolder.add(AnnotationsHighlightUtil.checkAnnotationType(annotation));
if (!myHolder.hasErrorResults()) myHolder.add(AnnotationsHighlightUtil.checkMissingAttributes(annotation));
if (!myHolder.hasErrorResults()) myHolder.add(AnnotationsHighlightUtil.checkTargetAnnotationDuplicates(annotation));
@@ -1240,7 +1239,7 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
}
}
}
if (!myHolder.hasErrorResults()) {
myHolder.add(PsiMethodReferenceHighlightingUtil.checkRawConstructorReference(expression));
}

View File

@@ -27,4 +27,10 @@ interface I {
@interface Caller {
Anno anno() default @Anno;
}
}
@interface AnnoArray {
@interface Part { }
Part[] arrayValue() default {@Part, @Part};
}