@Nullable
 public static PsiAnnotation getAnnotation(
     @NotNull PsiModifierListOwner field, @NotNull String annotationName) {
   final PsiModifierList modifierList = field.getModifierList();
   if (modifierList == null) return null;
   return modifierList.findAnnotation(annotationName);
 }
Example #2
0
  public static boolean isAnnotatedCheckHierarchyWithCache(
      @NotNull PsiClass aClass, @NotNull String annotationFQN) {
    Map<String, PsiClass> classMap = getSuperClassesWithCache(aClass);

    for (PsiClass psiClass : classMap.values()) {
      PsiModifierList modifierList = psiClass.getModifierList();
      if (modifierList != null) {
        if (modifierList.findAnnotation(annotationFQN) != null) {
          return true;
        }
      }
    }

    return false;
  }