PsiElementVisitor (@NotNull ProblemsHolder holder, boolean isOnTheFly) { List<VisibilityChecker> checkers = new ArrayList<>(2); if (checkModuleApi) { PsiFile file = holder.getFile(); if (file instanceof PsiJavaFile javaFile) { if (javaFile.getLanguageLevel().isAtLeast(LanguageLevel.JDK_1_9)) { PsiJavaModule psiModule = JavaModuleGraphUtil.findDescriptorByElement(file); if (psiModule != null) { VirtualFile vFile = file.getVirtualFile(); if (vFile != null) { Module module = ProjectFileIndex.getInstance(holder.getProject()).getModuleForFile(vFile); if (module != null) { Set<String> exportedPackageNames = new HashSet<>(ContainerUtil.mapNotNull(psiModule.getExports(), PsiPackageAccessibilityStatement::getPackageName)); if (exportedPackageNames.contains(javaFile.getPackageName())) { checkers.add(new Java9NonAccessibleTypeExposedVisitor(holder, module, psiModule.getName(), exportedPackageNames)); } } } } } } } if (checkPublicApi || checkPackageLocal) { checkers.add(new ClassEscapesItsScopeVisitor(holder)); } return !checkers.isEmpty() ? new VisibilityVisitor(checkers.toArray(VisibilityChecker.EMPTY_ARRAY)) : PsiElementVisitor.EMPTY_VISITOR; }