Search in sources :

Example 1 with GrRemoveAnnotationIntention

use of org.jetbrains.plugins.groovy.annotator.GrRemoveAnnotationIntention in project intellij-community by JetBrains.

the class AnnotationChecker method checkApplicability.

public void checkApplicability(@NotNull GrAnnotation annotation, @Nullable PsiAnnotationOwner owner) {
    final GrCodeReferenceElement ref = annotation.getClassReference();
    final PsiElement resolved = ref.resolve();
    if (resolved == null)
        return;
    assert resolved instanceof PsiClass;
    PsiClass anno = (PsiClass) resolved;
    String qname = anno.getQualifiedName();
    if (!anno.isAnnotationType() && GrAnnotationCollector.findAnnotationCollector(anno) == null) {
        if (qname != null) {
            myHolder.createErrorAnnotation(ref, GroovyBundle.message("class.is.not.annotation", qname));
        }
        return;
    }
    for (CustomAnnotationChecker checker : CustomAnnotationChecker.EP_NAME.getExtensions()) {
        if (checker.checkApplicability(myHolder, annotation))
            return;
    }
    String description = CustomAnnotationChecker.isAnnotationApplicable(annotation, owner);
    if (description != null) {
        myHolder.createErrorAnnotation(ref, description).registerFix(new GrRemoveAnnotationIntention());
    }
}
Also used : GrCodeReferenceElement(org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement) GrRemoveAnnotationIntention(org.jetbrains.plugins.groovy.annotator.GrRemoveAnnotationIntention) PsiClass(com.intellij.psi.PsiClass) PsiElement(com.intellij.psi.PsiElement)

Aggregations

PsiClass (com.intellij.psi.PsiClass)1 PsiElement (com.intellij.psi.PsiElement)1 GrRemoveAnnotationIntention (org.jetbrains.plugins.groovy.annotator.GrRemoveAnnotationIntention)1 GrCodeReferenceElement (org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement)1