boolean (PsiModifierListOwner element, boolean checkHierarchy, boolean checkDisabled, boolean checkJavadoc) { final PsiClass aClass; if (element instanceof PsiClass) { aClass = ((PsiClass)element); } else if (element instanceof PsiMethod) { aClass = ((PsiMethod)element).getContainingClass(); } else { aClass = null; } if (aClass == null || !PsiClassUtil.isRunnableClass(aClass, true, false)) { return false; } //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 ? AnnotationUtil.CHECK_HIERARCHY : 0); if (hasAnnotation) { if (checkDisabled) { PsiAnnotation annotation = AnnotationUtil.findAnnotation(element, true, TEST_ANNOTATION_FQN); if (annotation != null) { if (isDisabled(annotation)) return false; } } return true; } if (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, 0)) return true; if (checkJavadoc && getTextJavaDoc(method) != null) return true; } return false; } else { //even if it has a global test, we ignore non-public and static methods if (!element.hasModifierProperty(PsiModifier.PUBLIC) || 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; }