Пример #1
0
 public static boolean isAnnotatedWithParameter(
     PsiAnnotation annotation, String parameter, Set<String> values) {
   final PsiAnnotationMemberValue attributeValue =
       annotation.findDeclaredAttributeValue(parameter);
   if (attributeValue != null) {
     Collection<String> matches = extractValuesFromParameter(attributeValue);
     for (String s : matches) {
       if (values.contains(s)) {
         return true;
       }
     }
   }
   return false;
 }
Пример #2
0
 public static PsiClass getProviderClass(final PsiElement element, final PsiClass topLevelClass) {
   final PsiAnnotation annotation = PsiTreeUtil.getParentOfType(element, PsiAnnotation.class);
   if (annotation != null) {
     final PsiAnnotationMemberValue value =
         annotation.findDeclaredAttributeValue("dataProviderClass");
     if (value instanceof PsiClassObjectAccessExpression) {
       final PsiTypeElement operand = ((PsiClassObjectAccessExpression) value).getOperand();
       final PsiClass psiClass = PsiUtil.resolveClassInType(operand.getType());
       if (psiClass != null) {
         return psiClass;
       }
     }
   }
   return topLevelClass;
 }
Пример #3
0
 private static void appendAnnotationAttributeValues(
     final Map<String, Collection<String>> results,
     final PsiAnnotation annotation,
     final PsiDocCommentOwner commentOwner) {
   for (String parameter : results.keySet()) {
     final Collection<String> values = results.get(parameter);
     if (annotation != null) {
       final PsiAnnotationMemberValue value = annotation.findDeclaredAttributeValue(parameter);
       if (value != null) {
         values.addAll(extractValuesFromParameter(value));
       }
     } else {
       values.addAll(extractAnnotationValuesFromJavaDoc(getTextJavaDoc(commentOwner), parameter));
     }
   }
 }
Пример #4
0
 public static boolean isDisabled(PsiAnnotation annotation) {
   final PsiAnnotationMemberValue attributeValue =
       annotation.findDeclaredAttributeValue("enabled");
   return attributeValue != null && attributeValue.textMatches("false");
 }