PsiElementVisitor (final @NotNull ProblemsHolder holder, final boolean isOnTheFly) { return new JavaElementVisitor() { @Override public void visitAnnotation(@NotNull PsiAnnotation annotation) { if (TestNGUtil.TEST_ANNOTATION_FQN.equals(annotation.getQualifiedName())) { final PsiAnnotationMemberValue provider = annotation.findDeclaredAttributeValue("dataProvider"); if (provider != null && !TestNGUtil.isDisabled(annotation)) { for (PsiReference reference : provider.getReferences()) { if (reference instanceof DataProviderReference) { final PsiElement dataProviderMethod = reference.resolve(); final PsiElement element = reference.getElement(); final PsiClass topLevelClass = PsiUtil.getTopLevelClass(element); final PsiClass providerClass = TestNGUtil.getProviderClass(element, topLevelClass); if (!(dataProviderMethod instanceof PsiMethod providerMethod)) { final LocalQuickFix[] fixes; if (isOnTheFly && providerClass != null) { fixes = new LocalQuickFix[] {createMethodFix(provider, providerClass, topLevelClass)}; } else { fixes = LocalQuickFix.EMPTY_ARRAY; } holder.registerProblem(provider, TestngBundle.message("inspection.testng.data.provider.does.not.exist.problem"), fixes); } else { if (TestNGUtil.isVersionOrGreaterThan(holder.getProject(), ModuleUtilCore.findModuleForPsiElement(providerClass), 6, 9, 13)) { break; } if (providerClass != topLevelClass && !providerMethod.hasModifierProperty(PsiModifier.STATIC)) { holder.registerProblem(provider, TestngBundle.message("inspection.testng.data.provider.need.to.be.static")); } } break; } } } } } }; }