private static void addClassesInDirectory(@NotNull PsiDirectory dir,
                                            boolean includeSubdirs,
                                            @NotNull List<? super PsiClass> array) {
    ApplicationManager.getApplication().runReadAction(() -> {
      PsiClass[] classes = JavaDirectoryService.getInstance().getClasses(dir);
      ContainerUtil.addAll(array, classes);
      if (includeSubdirs) {
        PsiDirectory[] dirs = dir.getSubdirectories();
        for (PsiDirectory directory : dirs) {
          addClassesInDirectory(directory, true, array);
        }
      }
    });
  }
private static void addClassesInDirectory(@NotNull PsiDirectory dir,
                                            boolean includeSubdirs,
                                            @NotNull List<? super PsiClass> array)