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();
}
Aggregations