Search in sources :

Example 6 with SyncCanceledException

use of com.google.idea.blaze.base.sync.SyncScope.SyncCanceledException in project intellij by bazelbuild.

the class ProjectStateSyncTask method getProjectState.

private SyncProjectState getProjectState(BlazeContext context) throws SyncFailedException, SyncCanceledException {
    if (!FileOperationProvider.getInstance().exists(workspaceRoot.directory())) {
        IssueOutput.error(String.format("Workspace '%s' doesn't exist.", workspaceRoot.directory())).submit(context);
        throw new SyncFailedException();
    }
    BlazeVcsHandler vcsHandler = BlazeVcsHandler.vcsHandlerForProject(project);
    if (vcsHandler == null) {
        IssueOutput.error("Could not find a VCS handler").submit(context);
        throw new SyncFailedException();
    }
    ListeningExecutorService executor = BlazeExecutor.getInstance().getExecutor();
    WorkspacePathResolverAndProjectView workspacePathResolverAndProjectView = computeWorkspacePathResolverAndProjectView(context, vcsHandler, executor);
    if (workspacePathResolverAndProjectView == null) {
        throw new SyncFailedException();
    }
    ProjectViewSet projectViewSet = workspacePathResolverAndProjectView.projectViewSet;
    List<String> syncFlags = BlazeFlags.blazeFlags(project, projectViewSet, BlazeCommandName.INFO, context, BlazeInvocationContext.SYNC_CONTEXT);
    ListenableFuture<BlazeInfo> blazeInfoFuture = BlazeInfoRunner.getInstance().runBlazeInfo(context, importSettings.getBuildSystem(), Blaze.getBuildSystemProvider(project).getBinaryPath(project), workspaceRoot, syncFlags);
    ListenableFuture<WorkingSet> workingSetFuture = vcsHandler.getWorkingSet(project, context, workspaceRoot, executor);
    BlazeInfo blazeInfo = FutureUtil.waitForFuture(context, blazeInfoFuture).timed(Blaze.buildSystemName(project) + "Info", EventType.BlazeInvocation).withProgressMessage(String.format("Running %s info...", Blaze.buildSystemName(project))).onError(String.format("Could not run %s info", Blaze.buildSystemName(project))).run().result();
    if (blazeInfo == null) {
        throw new SyncFailedException();
    }
    BlazeVersionData blazeVersionData = BlazeVersionData.build(Blaze.getBuildSystemProvider(project).getBuildSystem(), workspaceRoot, blazeInfo);
    if (!BuildSystemVersionChecker.verifyVersionSupported(context, blazeVersionData)) {
        throw new SyncFailedException();
    }
    WorkspacePathResolver workspacePathResolver = workspacePathResolverAndProjectView.workspacePathResolver;
    WorkspaceLanguageSettings workspaceLanguageSettings = LanguageSupport.createWorkspaceLanguageSettings(projectViewSet);
    if (!ProjectViewVerifier.verifyProjectView(project, context, workspacePathResolver, projectViewSet, workspaceLanguageSettings)) {
        throw new SyncFailedException();
    }
    WorkingSet workingSet = FutureUtil.waitForFuture(context, workingSetFuture).timed("WorkingSet", EventType.Other).withProgressMessage("Computing VCS working set...").onError("Could not compute working set").run().result();
    if (context.isCancelled()) {
        throw new SyncCanceledException();
    }
    if (context.hasErrors()) {
        throw new SyncFailedException();
    }
    if (workingSet != null) {
        printWorkingSet(context, workingSet);
    }
    return SyncProjectState.builder().setProjectViewSet(projectViewSet).setLanguageSettings(workspaceLanguageSettings).setBlazeVersionData(blazeVersionData).setWorkingSet(workingSet).setWorkspacePathResolver(workspacePathResolver).build();
}
Also used : ProjectViewSet(com.google.idea.blaze.base.projectview.ProjectViewSet) SyncFailedException(com.google.idea.blaze.base.sync.SyncScope.SyncFailedException) BlazeInfo(com.google.idea.blaze.base.command.info.BlazeInfo) BlazeVersionData(com.google.idea.blaze.base.model.BlazeVersionData) SyncCanceledException(com.google.idea.blaze.base.sync.SyncScope.SyncCanceledException) ListeningExecutorService(com.google.common.util.concurrent.ListeningExecutorService) WorkspacePathResolver(com.google.idea.blaze.base.sync.workspace.WorkspacePathResolver) WorkspaceLanguageSettings(com.google.idea.blaze.base.sync.projectview.WorkspaceLanguageSettings) WorkingSet(com.google.idea.blaze.base.sync.workspace.WorkingSet) BlazeVcsHandler(com.google.idea.blaze.base.vcs.BlazeVcsHandler)

Aggregations

SyncCanceledException (com.google.idea.blaze.base.sync.SyncScope.SyncCanceledException)6 SyncFailedException (com.google.idea.blaze.base.sync.SyncScope.SyncFailedException)6 TargetExpression (com.google.idea.blaze.base.model.primitives.TargetExpression)4 ProjectViewSet (com.google.idea.blaze.base.projectview.ProjectViewSet)4 TimingScope (com.google.idea.blaze.base.scope.scopes.TimingScope)4 ImmutableList (com.google.common.collect.ImmutableList)2 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)2 BuildInvoker (com.google.idea.blaze.base.bazel.BuildSystem.BuildInvoker)2 SyncStrategy (com.google.idea.blaze.base.bazel.BuildSystem.SyncStrategy)2 TargetInfo (com.google.idea.blaze.base.dependencies.TargetInfo)2 BlazeProjectData (com.google.idea.blaze.base.model.BlazeProjectData)2 BlazeContext (com.google.idea.blaze.base.scope.BlazeContext)2 StatusOutput (com.google.idea.blaze.base.scope.output.StatusOutput)2 EventType (com.google.idea.blaze.base.scope.scopes.TimingScope.EventType)2 Blaze (com.google.idea.blaze.base.settings.Blaze)2 ImportRoots (com.google.idea.blaze.base.sync.projectview.ImportRoots)2 WorkspaceLanguageSettings (com.google.idea.blaze.base.sync.projectview.WorkspaceLanguageSettings)2 WorkspacePathResolver (com.google.idea.blaze.base.sync.workspace.WorkspacePathResolver)2 Project (com.intellij.openapi.project.Project)2 List (java.util.List)2