public TreeModel build(final Project project, final boolean showProgress, @Nullable final Runnable successRunnable) {
    final Runnable buildingRunnable = () -> {
      ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
      if (indicator != null) {
        indicator.setText(getScanningPackagesMessage());
        indicator.setIndeterminate(true);
      }
      countFiles(project);
      if (indicator != null) {
        indicator.setIndeterminate(false);
      }
      myFileIndex.iterateContent(new MyContentIterator());
      VirtualFile[] roots = LibraryUtil.getLibraryRoots(project);
      for (VirtualFile root : roots) {
        if (!ContainerUtil.exists(roots, r -> VfsUtilCore.isAncestor(r, root, true))) {
          processFilesRecursively(root);
        }
      }
    };
    final TreeModel treeModel = new TreeModel(myRoot);
    if (showProgress) {
      final Task.Backgroundable backgroundable =
        new Task.Backgroundable(project, CodeInsightBundle.message("package.dependencies.build.process.title")) {
          @Override
          public void run(@NotNull ProgressIndicator indicator) {
            buildingRunnable.run();
          }

          @Override
          public void onSuccess() {
            if (project.isDisposed()) return;
            myRoot.setSorted(false);
            myRoot.sortChildren();
            treeModel.reload(myRoot);
            if (successRunnable != null) {
              successRunnable.run();
            }
          }
        };
      ProgressManager.getInstance().run(backgroundable);
    }
    else {
      buildingRunnable.run();
    }

    treeModel.setTotalFileCount(myTotalFileCount);
    treeModel.setMarkedFileCount(myMarkedFileCount);
    return treeModel;
  }
public TreeModel build(final Project project, final boolean showProgress, @Nullable final Runnable successRunnable)