@Override
  public @NotNull PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder, boolean isOnTheFly) {
    return new JavaElementVisitor() {
      @Override
      public void visitClass(@NotNull PsiClass psiClass) {
        PsiIdentifier identifier = psiClass.getNameIdentifier();
        if (identifier == null) return;
        PsiFile containingFile = tryCast(psiClass.getContainingFile(), PsiJavaFile.class);
        if (containingFile == null) return;
        PsiModifierList modifiers = psiClass.getModifierList();
        if (modifiers == null || !modifiers.hasExplicitModifier(PsiModifier.SEALED)) return;
        Set<PsiClass> permittedClasses = ContainerUtil.map2Set(psiClass.getPermitsListTypes(), PsiClassType::resolve);
        for (PsiClass inheritor : DirectClassInheritorsSearch.search(psiClass)) {
          if (PsiUtil.isLocalOrAnonymousClass(inheritor)) return;
          // handled in highlighter
          if (inheritor.getContainingFile() != containingFile) return;
          if (!permittedClasses.contains(inheritor)) {
            holder.problem(identifier, JavaBundle.message("inspection.fill.permits.list.display.name"))
              .fix(new FillPermitsListFix(identifier)).register();
            break;
          }
        }
      }
    };
  }
@Override
  public @NotNull PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder, boolean isOnTheFly)