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; }
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; }
public static boolean isTestNGAnnotation(PsiAnnotation annotation) { String qName = annotation.getQualifiedName(); if (qName != null) { if (qName.equals(TEST_ANNOTATION_FQN)) return true; for (String qn : CONFIG_ANNOTATIONS_FQN) { if (qName.equals(qn)) return true; } if (qName.equals(TEST_ANNOTATION_FQN)) return true; for (String qn : CONFIG_ANNOTATIONS_FQN) { if (qName.equals(qn)) return true; } } return false; }
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)); } } }
public static boolean isDisabled(PsiAnnotation annotation) { final PsiAnnotationMemberValue attributeValue = annotation.findDeclaredAttributeValue("enabled"); return attributeValue != null && attributeValue.textMatches("false"); }