package com.siyeh.ig.jdk;

import com.intellij.codeInsight.daemon.GroupNames;
import com.intellij.codeInspection.InspectionManager;
import com.intellij.codeInspection.ProblemDescriptor;
import com.intellij.psi.*;
import com.siyeh.ig.BaseInspection;
import com.siyeh.ig.BaseInspectionVisitor;

public class AnnotationInspection extends BaseInspection {

    public String getDisplayName() {
        return "Annotation";
    }

    public String getGroupDisplayName() {
        return GroupNames.JDK_GROUP_NAME;
    }

    public ProblemDescriptor[] doCheckClass(PsiClass aClass,
                                            InspectionManager manager,
                                            boolean isOnTheFly) {
        if (!aClass.isPhysical()) {
            return super.doCheckClass(aClass, manager, isOnTheFly);
        }
        final BaseInspectionVisitor visitor = createVisitor(manager, isOnTheFly);
        aClass.accept(visitor);

        return visitor.getErrors();
    }

    public ProblemDescriptor[] doCheckMethod(PsiMethod method,
                                             InspectionManager manager,
                                             boolean isOnTheFly) {
        if (!method.isPhysical()) {
            return super.doCheckMethod(method, manager, isOnTheFly);
        }
        final BaseInspectionVisitor visitor = createVisitor(manager, isOnTheFly);
        method.accept(visitor);
        return visitor.getErrors();
    }

    public ProblemDescriptor[] doCheckField(PsiField field,
                                            InspectionManager manager,
                                            boolean isOnTheFly) {
        if (!field.isPhysical()) {
            return super.doCheckField(field, manager, isOnTheFly);
        }
        final BaseInspectionVisitor visitor = createVisitor(manager, isOnTheFly);
        field.accept(visitor);
        return visitor.getErrors();
    }

    public String buildErrorString(PsiElement location) {
        return "Annotation '#ref' #loc";
    }

    public BaseInspectionVisitor buildVisitor() {
        return new UnnecessaryInterfaceModifierVisitor();
    }

    private static class UnnecessaryInterfaceModifierVisitor extends BaseInspectionVisitor {
        public void visitAnnotation(PsiAnnotation annotation) {
            super.visitAnnotation(annotation);
            registerError(annotation);
        }
    }
}

@@ -95,121 +95,61 @@
 lij.
-codeInspection.InspectionManager;%0Aimport com.intellij.codeInspection.ProblemDescriptor;%0Aimport com.intellij.psi.*
+psi.PsiAnnotation;%0Aimport com.intellij.psi.PsiElement
 ;%0Aim
@@ -176,24 +176,31 @@
 seInspection
+Visitor
 ;%0Aimport com
@@ -201,36 +201,37 @@
 rt com.siyeh.ig.
-Base
+Class
 InspectionVisito
@@ -224,23 +224,16 @@
 spection
-Visitor
 ;%0A%0Apubli
@@ -261,36 +261,37 @@
 pection extends 
-Base
+Class
 Inspection %7B%0A%0A  
@@ -456,1417 +456,8 @@
  %7D%0A%0A
-    public ProblemDescriptor%5B%5D doCheckClass(PsiClass aClass,%0A                                            InspectionManager manager,%0A                                            boolean isOnTheFly) %7B%0A        if (!aClass.isPhysical()) %7B%0A            return super.doCheckClass(aClass, manager, isOnTheFly);%0A        %7D%0A        final BaseInspectionVisitor visitor = createVisitor(manager, isOnTheFly);%0A        aClass.accept(visitor);%0A%0A        return visitor.getErrors();%0A    %7D%0A%0A    public ProblemDescriptor%5B%5D doCheckMethod(PsiMethod method,%0A                                             InspectionManager manager,%0A                                             boolean isOnTheFly) %7B%0A        if (!method.isPhysical()) %7B%0A            return super.doCheckMethod(method, manager, isOnTheFly);%0A        %7D%0A        final BaseInspectionVisitor visitor = createVisitor(manager, isOnTheFly);%0A        method.accept(visitor);%0A        return visitor.getErrors();%0A    %7D%0A%0A    public ProblemDescriptor%5B%5D doCheckField(PsiField field,%0A                                            InspectionManager manager,%0A                                            boolean isOnTheFly) %7B%0A        if (!field.isPhysical()) %7B%0A            return super.doCheckField(field, manager, isOnTheFly);%0A        %7D%0A        final BaseInspectionVisitor visitor = createVisitor(manager, isOnTheFly);%0A        field.accept(visitor);%0A        return visitor.getErrors();%0A    %7D%0A%0A
     

Fix for IDEA-2902