private void run()

in base/src/com/google/idea/blaze/base/sync/ProjectUpdateSyncTask.java [151:256]


  private void run(BlazeContext context) throws SyncCanceledException, SyncFailedException {
    TargetMap targetMap = targetData.targetMap;
    RemoteOutputArtifacts oldRemoteState = RemoteOutputArtifacts.fromProjectData(oldProjectData);
    RemoteOutputArtifacts newRemoteState = targetData.remoteOutputs;

    ArtifactLocationDecoder artifactLocationDecoder =
        new ArtifactLocationDecoderImpl(
            projectState.getBlazeInfo(), projectState.getWorkspacePathResolver(), newRemoteState);

    Scope.push(
        context,
        childContext -> {
          childContext.push(new TimingScope("UpdateRemoteOutputsCache", EventType.Prefetching));
          RemoteOutputsCache.getInstance(project)
              .updateCache(
                  context,
                  targetMap,
                  projectState.getLanguageSettings(),
                  newRemoteState,
                  oldRemoteState,
                  /* clearCache= */ syncMode == SyncMode.FULL);
        });

    SyncState.Builder syncStateBuilder = new SyncState.Builder();
    Scope.push(
        context,
        childContext -> {
          childContext.push(new TimingScope("UpdateSyncState", EventType.Other));
          for (BlazeSyncPlugin syncPlugin : BlazeSyncPlugin.EP_NAME.getExtensions()) {
            syncPlugin.updateSyncState(
                project,
                childContext,
                workspaceRoot,
                projectState.getProjectViewSet(),
                projectState.getLanguageSettings(),
                projectState.getBlazeVersionData(),
                projectState.getWorkingSet(),
                artifactLocationDecoder,
                targetMap,
                syncStateBuilder,
                oldProjectData != null ? oldProjectData.getSyncState() : null,
                syncMode);
          }
        });
    if (context.isCancelled()) {
      throw new SyncCanceledException();
    }
    if (context.hasErrors()) {
      throw new SyncFailedException();
    }

    BlazeProjectData newProjectData =
        new BlazeProjectData(
            targetData,
            projectState.getBlazeInfo(),
            projectState.getBlazeVersionData(),
            projectState.getWorkspacePathResolver(),
            artifactLocationDecoder,
            projectState.getLanguageSettings(),
            syncStateBuilder.build());

    FileCaches.onSync(
        project,
        context,
        projectState.getProjectViewSet(),
        newProjectData,
        oldProjectData,
        syncMode);
    ListenableFuture<?> prefetch =
        PrefetchService.getInstance()
            .prefetchProjectFiles(project, projectState.getProjectViewSet(), newProjectData);
    FutureUtil.waitForFuture(context, prefetch)
        .withProgressMessage("Prefetching files...")
        .timed("PrefetchFiles", EventType.Prefetching)
        .onError("Prefetch failed")
        .run();

    ListenableFuture<DirectoryStructure> directoryStructureFuture =
        DirectoryStructure.getRootDirectoryStructure(
            project, workspaceRoot, projectState.getProjectViewSet());

    refreshVirtualFileSystem(context, project, newProjectData);

    DirectoryStructure directoryStructure =
        FutureUtil.waitForFuture(context, directoryStructureFuture)
            .withProgressMessage("Computing directory structure...")
            .timed("DirectoryStructure", EventType.Other)
            .onError("Directory structure computation failed")
            .run()
            .result();
    if (directoryStructure == null) {
      throw new SyncFailedException();
    }

    boolean success =
        updateProject(
            context,
            projectState.getProjectViewSet(),
            projectState.getBlazeVersionData(),
            directoryStructure,
            oldProjectData,
            newProjectData);
    if (!success) {
      throw new SyncFailedException();
    }
  }