Search in sources :

Example 11 with StatusOutput

use of com.google.idea.blaze.base.scope.output.StatusOutput in project intellij by bazelbuild.

the class BlazeBeforeRunCommandHelper method runBlazeBuild.

/**
 * Kicks off the blaze build task, returning a corresponding {@link ListenableFuture}.
 */
public static ListenableFuture<BuildResult> runBlazeBuild(BlazeCommandRunConfiguration configuration, BuildResultHelper buildResultHelper, List<String> requiredExtraBlazeFlags, List<String> overridableExtraBlazeFlags, String progressMessage) {
    Project project = configuration.getProject();
    BlazeCommandRunConfigurationCommonState handlerState = (BlazeCommandRunConfigurationCommonState) configuration.getHandler().getState();
    WorkspaceRoot workspaceRoot = WorkspaceRoot.fromProject(project);
    ProjectViewSet projectViewSet = ProjectViewManager.getInstance(project).getProjectViewSet();
    String binaryPath = handlerState.getBlazeBinaryState().getBlazeBinary() != null ? handlerState.getBlazeBinaryState().getBlazeBinary() : Blaze.getBuildSystemProvider(project).getBinaryPath();
    BlazeConsolePopupBehavior consolePopupBehavior = BlazeUserSettings.getInstance().getSuppressConsoleForRunAction() ? BlazeConsolePopupBehavior.NEVER : BlazeConsolePopupBehavior.ALWAYS;
    return ProgressiveTaskWithProgressIndicator.builder(project).submitTaskWithResult(new ScopedTask<BuildResult>() {

        @Override
        protected BuildResult execute(BlazeContext context) {
            context.push(new IssuesScope(project, true)).push(new BlazeConsoleScope.Builder(project).setPopupBehavior(consolePopupBehavior).addConsoleFilters(new IssueOutputFilter(project, workspaceRoot, BlazeInvocationContext.NonSync, true)).build());
            context.output(new StatusOutput(progressMessage));
            BlazeCommand.Builder command = BlazeCommand.builder(binaryPath, BlazeCommandName.BUILD).addTargets(configuration.getTarget()).addBlazeFlags(overridableExtraBlazeFlags).addBlazeFlags(BlazeFlags.blazeFlags(project, projectViewSet, BlazeCommandName.BUILD, BlazeInvocationContext.NonSync)).addBlazeFlags(handlerState.getBlazeFlagsState().getExpandedFlags()).addBlazeFlags(requiredExtraBlazeFlags).addBlazeFlags(buildResultHelper.getBuildFlags());
            int exitCode = ExternalTask.builder(workspaceRoot).addBlazeCommand(command.build()).context(context).stderr(LineProcessingOutputStream.of(BlazeConsoleLineProcessorProvider.getAllStderrLineProcessors(context))).build().run();
            return BuildResult.fromExitCode(exitCode);
        }
    });
}
Also used : BlazeCommandRunConfigurationCommonState(com.google.idea.blaze.base.run.state.BlazeCommandRunConfigurationCommonState) ProjectViewSet(com.google.idea.blaze.base.projectview.ProjectViewSet) IssueOutputFilter(com.google.idea.blaze.base.issueparser.IssueOutputFilter) StatusOutput(com.google.idea.blaze.base.scope.output.StatusOutput) WorkspaceRoot(com.google.idea.blaze.base.model.primitives.WorkspaceRoot) Project(com.intellij.openapi.project.Project) BuildResult(com.google.idea.blaze.base.sync.aspects.BuildResult) BlazeContext(com.google.idea.blaze.base.scope.BlazeContext) BlazeConsoleScope(com.google.idea.blaze.base.scope.scopes.BlazeConsoleScope) IssuesScope(com.google.idea.blaze.base.scope.scopes.IssuesScope) BlazeConsolePopupBehavior(com.google.idea.blaze.base.settings.BlazeUserSettings.BlazeConsolePopupBehavior)

Example 12 with StatusOutput

use of com.google.idea.blaze.base.scope.output.StatusOutput in project intellij by bazelbuild.

the class FileCaches method onSync.

/**
 * Call on sync. Updates the file cache and deletes any old files.
 */
public static void onSync(Project project, BlazeContext context, ProjectViewSet projectViewSet, BlazeProjectData blazeProjectData, BlazeSyncParams.SyncMode syncMode) {
    for (FileCache fileCache : FileCache.EP_NAME.getExtensions()) {
        Scope.push(context, childContext -> {
            childContext.push(new TimingScope(fileCache.getName(), EventType.Other));
            childContext.output(new StatusOutput("Updating " + fileCache.getName() + "..."));
            fileCache.onSync(project, context, projectViewSet, blazeProjectData, syncMode);
        });
    }
    LocalFileSystem.getInstance().refresh(true);
}
Also used : TimingScope(com.google.idea.blaze.base.scope.scopes.TimingScope) StatusOutput(com.google.idea.blaze.base.scope.output.StatusOutput)

Example 13 with StatusOutput

use of com.google.idea.blaze.base.scope.output.StatusOutput in project intellij by bazelbuild.

the class NewBlazePackageAction method actionPerformedInBlazeProject.

@Override
protected void actionPerformedInBlazeProject(Project project, AnActionEvent event) {
    final IdeView view = event.getData(LangDataKeys.IDE_VIEW);
    Scope.root(context -> {
        if (view == null || project == null) {
            return;
        }
        PsiDirectory directory = getOrChooseDirectory(project, view);
        if (directory == null) {
            return;
        }
        NewBlazePackageDialog newBlazePackageDialog = new NewBlazePackageDialog(project, directory);
        boolean isOk = newBlazePackageDialog.showAndGet();
        if (!isOk) {
            return;
        }
        final Label newRule = newBlazePackageDialog.getNewRule();
        final Kind newRuleKind = newBlazePackageDialog.getNewRuleKind();
        // If we returned OK, we should have a non null result
        logger.assertTrue(newRule != null);
        logger.assertTrue(newRuleKind != null);
        context.output(new StatusOutput(String.format("Setting up a new %s package", Blaze.buildSystemName(project))));
        Optional<VirtualFile> virtualFile = createPackageOnDisk(project, context, newRule, newRuleKind);
        if (!virtualFile.isPresent()) {
            return;
        }
        PsiFile psiFile = PsiManager.getInstance(project).findFile(virtualFile.get());
        view.selectElement(psiFile);
    });
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) PsiDirectory(com.intellij.psi.PsiDirectory) Kind(com.google.idea.blaze.base.model.primitives.Kind) Label(com.google.idea.blaze.base.model.primitives.Label) StatusOutput(com.google.idea.blaze.base.scope.output.StatusOutput) PsiFile(com.intellij.psi.PsiFile) IdeView(com.intellij.ide.IdeView)

Example 14 with StatusOutput

use of com.google.idea.blaze.base.scope.output.StatusOutput in project intellij by bazelbuild.

the class BlazeSyncTask method updateProject.

private boolean updateProject(BlazeContext parentContext, ProjectViewSet projectViewSet, BlazeVersionData blazeVersionData, DirectoryStructure directoryStructure, @Nullable BlazeProjectData oldBlazeProjectData, BlazeProjectData newBlazeProjectData) {
    return Scope.push(parentContext, context -> {
        context.push(new TimingScope("UpdateProjectStructure", EventType.Other));
        context.output(new StatusOutput("Committing project structure..."));
        try {
            Transactions.submitWriteActionTransactionAndWait(() -> ProjectRootManagerEx.getInstanceEx(this.project).mergeRootsChangesDuring(() -> updateProjectStructure(context, importSettings, projectViewSet, blazeVersionData, directoryStructure, newBlazeProjectData, oldBlazeProjectData)));
        } catch (ProcessCanceledException e) {
            context.setCancelled();
            throw e;
        } catch (Throwable e) {
            IssueOutput.error("Internal error. Error: " + e).submit(context);
            logger.error(e);
            return false;
        }
        BlazeProjectDataManagerImpl.getImpl(project).saveProject(importSettings, newBlazeProjectData);
        return true;
    });
}
Also used : TimingScope(com.google.idea.blaze.base.scope.scopes.TimingScope) StatusOutput(com.google.idea.blaze.base.scope.output.StatusOutput) ProcessCanceledException(com.intellij.openapi.progress.ProcessCanceledException)

Example 15 with StatusOutput

use of com.google.idea.blaze.base.scope.output.StatusOutput in project intellij by bazelbuild.

the class BlazeSyncTask method run.

@Override
public void run(final ProgressIndicator indicator) {
    Scope.root((BlazeContext context) -> {
        context.push(new ExperimentScope());
        if (showPerformanceWarnings) {
            context.push(new PerformanceWarningScope());
        }
        context.push(new ProgressIndicatorScope(indicator));
        if (!syncParams.backgroundSync) {
            context.push(new BlazeConsoleScope.Builder(project, indicator).setPopupBehavior(BlazeUserSettings.getInstance().getShowBlazeConsoleOnSync()).addConsoleFilters(new IssueOutputFilter(project, workspaceRoot, BlazeInvocationContext.Sync, true)).build()).push(new IssuesScope(project, true)).push(new IdeaLogScope()).push(new NotificationScope(project, "Sync", "Sync project", "Sync successful", "Sync failed"));
        }
        context.output(new StatusOutput(String.format("Syncing project: %s...", syncParams)));
        syncProject(context);
    });
}
Also used : PerformanceWarningScope(com.google.idea.blaze.base.scope.scopes.PerformanceWarningScope) IdeaLogScope(com.google.idea.blaze.base.scope.scopes.IdeaLogScope) BlazeContext(com.google.idea.blaze.base.scope.BlazeContext) BlazeConsoleScope(com.google.idea.blaze.base.scope.scopes.BlazeConsoleScope) IssueOutputFilter(com.google.idea.blaze.base.issueparser.IssueOutputFilter) ExperimentScope(com.google.idea.blaze.base.experiments.ExperimentScope) IssuesScope(com.google.idea.blaze.base.scope.scopes.IssuesScope) ProgressIndicatorScope(com.google.idea.blaze.base.scope.scopes.ProgressIndicatorScope) NotificationScope(com.google.idea.blaze.base.scope.scopes.NotificationScope) StatusOutput(com.google.idea.blaze.base.scope.output.StatusOutput)

Aggregations

StatusOutput (com.google.idea.blaze.base.scope.output.StatusOutput)16 TimingScope (com.google.idea.blaze.base.scope.scopes.TimingScope)8 IssueOutputFilter (com.google.idea.blaze.base.issueparser.IssueOutputFilter)3 Label (com.google.idea.blaze.base.model.primitives.Label)3 ProjectViewSet (com.google.idea.blaze.base.projectview.ProjectViewSet)3 BlazeContext (com.google.idea.blaze.base.scope.BlazeContext)3 BlazeConsoleScope (com.google.idea.blaze.base.scope.scopes.BlazeConsoleScope)3 IssuesScope (com.google.idea.blaze.base.scope.scopes.IssuesScope)3 BuildResult (com.google.idea.blaze.base.sync.aspects.BuildResult)3 Kind (com.google.idea.blaze.base.model.primitives.Kind)2 WorkspaceRoot (com.google.idea.blaze.base.model.primitives.WorkspaceRoot)2 BlazeConsolePopupBehavior (com.google.idea.blaze.base.settings.BlazeUserSettings.BlazeConsolePopupBehavior)2 BlazeIdeInterface (com.google.idea.blaze.base.sync.aspects.BlazeIdeInterface)2 Function (com.google.common.base.Function)1 Preconditions.checkArgument (com.google.common.base.Preconditions.checkArgument)1 Preconditions.checkState (com.google.common.base.Preconditions.checkState)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Futures (com.google.common.util.concurrent.Futures)1