PsiElementVisitor (@NotNull ProblemsHolder holder, boolean isOnTheFly) { return new JavaElementVisitor() { @Override public void visitJavaFile(@NotNull PsiJavaFile file) { if (PsiPackage.PACKAGE_INFO_FILE.equals(file.getName())) { checkFile(file, holder, isOnTheFly); } } @Override public void visitModule(@NotNull PsiJavaModule module) { checkModule(module, holder, isOnTheFly); } @Override public void visitClass(@NotNull PsiClass aClass) { checkClass(aClass, holder, isOnTheFly); } @Override public void visitField(@NotNull PsiField field) { checkField(field, holder, isOnTheFly); } @Override public void visitMethod(@NotNull PsiMethod method) { checkMethod(method, holder, isOnTheFly); } }; }