@Nullable
  private static HighlightInfo.Builder checkReferenceTarget(@NotNull PsiAnnotation annotation, @Nullable PsiJavaCodeReferenceElement ref) {
    if (ref == null) return null;
    PsiElement refTarget = ref.resolve();
    if (refTarget == null) return null;

    if (!(refTarget instanceof PsiClass)) {
      return createAnnotationError(annotation, JavaErrorBundle.message("annotation.not.allowed.ref"));
    }

    PsiElement parent = ref.getParent();
    while (parent instanceof PsiJavaCodeReferenceElement) {
      PsiElement qualified = ((PsiJavaCodeReferenceElement)parent).resolve();
      if (qualified instanceof PsiMember && ((PsiMember)qualified).hasModifierProperty(PsiModifier.STATIC)) {
        return createAnnotationError(annotation,
                                     JavaErrorBundle.message("annotation.not.allowed.static"),
                                     new MoveAnnotationOnStaticMemberQualifyingTypeFix(annotation).asIntention());
      }
      if (qualified instanceof PsiClass) {
        parent = parent.getParent();
      }
      else {
        break;
      }
    }
    return null;
  }
@Nullable
  private static HighlightInfo.Builder checkReferenceTarget(@NotNull PsiAnnotation annotation, @Nullable PsiJavaCodeReferenceElement ref)