public void build(boolean computeSubtypes) {

    JavaModelManager manager = JavaModelManager.getJavaModelManager();
    try {
      // optimize access to zip files while building hierarchy
      manager.cacheZipFiles();

      if (this.hierarchy.focusType == null || computeSubtypes) {
        IProgressMonitor typeInRegionMonitor =
            this.hierarchy.progressMonitor == null
                ? null
                : new SubProgressMonitor(this.hierarchy.progressMonitor, 30);
        HashMap allOpenablesInRegion = determineOpenablesInRegion(typeInRegionMonitor);
        this.hierarchy.initialize(allOpenablesInRegion.size());
        IProgressMonitor buildMonitor =
            this.hierarchy.progressMonitor == null
                ? null
                : new SubProgressMonitor(this.hierarchy.progressMonitor, 70);
        createTypeHierarchyBasedOnRegion(allOpenablesInRegion, buildMonitor);
        ((RegionBasedTypeHierarchy) this.hierarchy).pruneDeadBranches();
      } else {
        this.hierarchy.initialize(1);
        this.buildSupertypes();
      }
    } finally {
      manager.flushZipFiles();
    }
  }
 /**
  * Wait for the index manager for the given max time.
  *
  * @param max maximum amount of time to wait for the index manager
  */
 private static void waitForIndexManager(long max) {
   // Wait for the end of indexing
   IndexManager indexManager = JavaModelManager.getJavaModelManager().getIndexManager();
   long maxWaits = max / 10;
   while (indexManager.awaitingJobsCount() > 0 && maxWaits-- > 0) {
     try {
       Thread.sleep(10);
     } catch (InterruptedException e) {
       return;
     }
   }
 }