PsiElementVisitor (@NotNull final ProblemsHolder holder, boolean isOnTheFly) { return new JavaElementVisitor() { final String annotationName = getAnnotationName(holder.getProject()); @Override public void visitAnnotation(@NotNull PsiAnnotation annotation) { final String name = annotation.getQualifiedName(); if (annotationName.equals(name)) { checkAnnotation(annotation, holder); } else if (name != null) { final PsiClass psiClass = JavaPsiFacade.getInstance(annotation.getProject()).findClass(name, annotation.getResolveScope()); if (psiClass != null && AnnotationUtil.isAnnotated(psiClass, annotationName, CHECK_EXTERNAL)) { checkAnnotation(annotation, holder); } } } }; }