Skip to content

Commit

Permalink
Add support for the new sync view in query sync (#7037)
Browse files Browse the repository at this point in the history
  • Loading branch information
LeFrosch authored Nov 30, 2024
1 parent c75b165 commit 5733082
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import com.google.idea.blaze.base.bazel.BazelExitCodeException.ThrowOption;
import com.google.idea.blaze.base.bazel.BuildSystem;
import com.google.idea.blaze.base.bazel.BuildSystem.BuildInvoker;
import com.google.idea.blaze.base.buildview.BazelExecService;
import com.google.idea.blaze.base.command.BlazeCommand;
import com.google.idea.blaze.base.command.BlazeCommandName;
import com.google.idea.blaze.base.command.BlazeFlags;
Expand Down Expand Up @@ -211,8 +212,7 @@ public OutputInfo build(
buildDepsStatsBuilder.ifPresent(
stats -> stats.setBuildFlags(builder.build().toArgumentList()));
Instant buildTime = Instant.now();
BlazeBuildOutputs outputs =
invoker.getCommandRunner().run(project, builder, buildResultHelper, context, ImmutableMap.of());
BlazeBuildOutputs outputs = BazelExecService.instance(project).build(context, builder);
buildDepsStatsBuilder.ifPresent(
stats -> {
stats.setBuildIds(outputs.getBuildIds());
Expand Down
48 changes: 30 additions & 18 deletions base/src/com/google/idea/blaze/base/qsync/QuerySyncManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import com.google.common.util.concurrent.SettableFuture;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.idea.blaze.base.async.executor.ProgressiveTaskWithProgressIndicator;
import com.google.idea.blaze.base.buildview.BuildViewMigration;
import com.google.idea.blaze.base.buildview.BuildViewScope;
import com.google.idea.blaze.base.command.BlazeInvocationContext.ContextType;
import com.google.idea.blaze.base.issueparser.BlazeIssueParser;
import com.google.idea.blaze.base.logging.utils.querysync.QuerySyncActionStatsScope;
Expand Down Expand Up @@ -57,6 +59,7 @@
import com.intellij.notification.Notifications;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.ModificationTracker;
import com.intellij.openapi.vfs.VirtualFile;
Expand Down Expand Up @@ -359,30 +362,18 @@ private ListenableFuture<Boolean> createAndSubmitRunTask(
querySyncActionStatsScope.getBuilder().setTaskOrigin(taskOrigin);
BlazeUserSettings userSettings = BlazeUserSettings.getInstance();
return ProgressiveTaskWithProgressIndicator.builder(project, title)
.setModality(BuildViewMigration.progressModality())
.submitTaskWithResult(
indicator ->
Scope.root(
context -> {
Task task = new Task(project, subTitle, Task.Type.SYNC);
BlazeScope scope =
new ToolWindowScope.Builder(project, task)
.setProgressIndicator(indicator)
.showSummaryOutput()
.setPopupBehavior(
taskOrigin == TaskOrigin.AUTOMATIC
? showWindowOnAutomaticSyncErrors.getValue()
? FocusBehavior.ON_ERROR
: FocusBehavior.NEVER
: userSettings.getShowBlazeConsoleOnSync())
.setIssueParsers(
BlazeIssueParser.defaultIssueParsers(
project,
WorkspaceRoot.fromProject(project),
ContextType.Sync))
.build();
if (BuildViewMigration.getEnabled()) {
context.push(new BuildViewScope(project, title));
}

context
.push(new ProgressIndicatorScope(indicator))
.push(scope)
.push(buildToolWindowsScope(subTitle, indicator, taskOrigin))
.push(querySyncActionStatsScope)
.push(
new ProblemsViewScope(
Expand All @@ -397,6 +388,27 @@ private ListenableFuture<Boolean> createAndSubmitRunTask(
}));
}

private BlazeScope buildToolWindowsScope(String subTitle, ProgressIndicator indicator, TaskOrigin taskOrigin) {
Task task = new Task(project, subTitle, Task.Type.SYNC);
BlazeUserSettings userSettings = BlazeUserSettings.getInstance();

return new ToolWindowScope.Builder(project, task)
.setProgressIndicator(indicator)
.showSummaryOutput()
.setPopupBehavior(
taskOrigin == TaskOrigin.AUTOMATIC
? showWindowOnAutomaticSyncErrors.getValue()
? FocusBehavior.ON_ERROR
: FocusBehavior.NEVER
: userSettings.getShowBlazeConsoleOnSync())
.setIssueParsers(
BlazeIssueParser.defaultIssueParsers(
project,
WorkspaceRoot.fromProject(project),
ContextType.Sync))
.build();
}

@Nullable
public DependencyTracker getDependencyTracker() {
return loadedProject == null ? null : loadedProject.getDependencyTracker();
Expand Down

0 comments on commit 5733082

Please sign in to comment.