@NotNull public Iterable<PyElement> iterateNames() { return Collections.<PyElement>singleton(this); }
public static boolean hasTest( PsiModifierListOwner element, boolean checkHierarchy, boolean checkDisabled, boolean checkJavadoc) { // LanguageLevel effectiveLanguageLevel = element.getManager().getEffectiveLanguageLevel(); // boolean is15 = effectiveLanguageLevel != LanguageLevel.JDK_1_4 && effectiveLanguageLevel != // LanguageLevel.JDK_1_3; boolean hasAnnotation = AnnotationUtil.isAnnotated(element, TEST_ANNOTATION_FQN, checkHierarchy, true); if (hasAnnotation) { if (checkDisabled) { PsiAnnotation annotation = AnnotationUtil.findAnnotation(element, true, TEST_ANNOTATION_FQN); if (annotation != null) { if (isDisabled(annotation)) return false; } } return true; } if (element instanceof PsiDocCommentOwner && checkJavadoc && getTextJavaDoc((PsiDocCommentOwner) element) != null) return true; // now we check all methods for the test annotation if (element instanceof PsiClass) { PsiClass psiClass = (PsiClass) element; for (PsiMethod method : psiClass.getAllMethods()) { PsiAnnotation annotation = AnnotationUtil.findAnnotation(method, true, TEST_ANNOTATION_FQN); if (annotation != null) { if (checkDisabled) { if (isDisabled(annotation)) continue; } return true; } if (AnnotationUtil.isAnnotated(method, FACTORY_ANNOTATION_FQN, false, true)) return true; if (checkJavadoc && getTextJavaDoc(method) != null) return true; } return false; } else if (element instanceof PsiMethod) { // even if it has a global test, we ignore private and static methods if (element.hasModifierProperty(PsiModifier.PRIVATE) || element.hasModifierProperty(PsiModifier.STATIC)) { return false; } // if it's a method, we check if the class it's in has a global @Test annotation PsiClass psiClass = ((PsiMethod) element).getContainingClass(); if (psiClass != null) { final PsiAnnotation annotation = checkHierarchy ? AnnotationUtil.findAnnotationInHierarchy( psiClass, Collections.singleton(TEST_ANNOTATION_FQN)) : AnnotationUtil.findAnnotation(psiClass, true, TEST_ANNOTATION_FQN); if (annotation != null) { if (checkDisabled && isDisabled(annotation)) return false; return !hasConfig(element); } else if (checkJavadoc && getTextJavaDoc(psiClass) != null) return true; } } return false; }