Search in sources :

Example 6 with IssuesScope

use of com.google.idea.blaze.base.scope.scopes.IssuesScope 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 7 with IssuesScope

use of com.google.idea.blaze.base.scope.scopes.IssuesScope in project intellij by bazelbuild.

the class BlazeAndroidRunConfigurationRunner method executeBeforeRunTask.

@Override
public boolean executeBeforeRunTask(ExecutionEnvironment env) {
    final Project project = env.getProject();
    BlazeConsolePopupBehavior consolePopupBehavior = BlazeUserSettings.getInstance().getSuppressConsoleForRunAction() ? BlazeConsolePopupBehavior.NEVER : BlazeConsolePopupBehavior.ALWAYS;
    return Scope.root(context -> {
        context.push(new IssuesScope(project, true)).push(new ExperimentScope()).push(new BlazeConsoleScope.Builder(project).setPopupBehavior(consolePopupBehavior).addConsoleFilters(new IssueOutputFilter(project, WorkspaceRoot.fromProject(project), BlazeInvocationContext.NonSync, true)).build()).push(new IdeaLogScope());
        BlazeAndroidRunContext runContext = env.getCopyableUserData(RUN_CONTEXT_KEY);
        if (runContext == null) {
            IssueOutput.error("Could not find run context. Please try again").submit(context);
            return false;
        }
        BlazeAndroidDeviceSelector.DeviceSession deviceSession = env.getCopyableUserData(DEVICE_SESSION_KEY);
        BlazeApkBuildStep buildStep = runContext.getBuildStep();
        try {
            return buildStep.build(context, deviceSession);
        } catch (Exception e) {
            LOG.error(e);
            return false;
        }
    });
}
Also used : IssueOutputFilter(com.google.idea.blaze.base.issueparser.IssueOutputFilter) ExperimentScope(com.google.idea.blaze.base.experiments.ExperimentScope) ApkProvisionException(com.android.tools.idea.run.ApkProvisionException) ExecutionException(com.intellij.execution.ExecutionException) Project(com.intellij.openapi.project.Project) IdeaLogScope(com.google.idea.blaze.base.scope.scopes.IdeaLogScope) 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 8 with IssuesScope

use of com.google.idea.blaze.base.scope.scopes.IssuesScope in project intellij by bazelbuild.

the class NewBlazeRuleAction method actionPerformedInBlazeProject.

@Override
protected void actionPerformedInBlazeProject(Project project, AnActionEvent event) {
    final VirtualFile virtualFile = event.getData(CommonDataKeys.VIRTUAL_FILE);
    if (virtualFile == null) {
        return;
    }
    Scope.root(context -> {
        context.push(new ExperimentScope()).push(new BlazeConsoleScope.Builder(project).build()).push(new IssuesScope(project, true)).push(new IdeaLogScope());
        NewBlazeRuleDialog newBlazeRuleDialog = new NewBlazeRuleDialog(project, virtualFile);
        newBlazeRuleDialog.show();
    });
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) IdeaLogScope(com.google.idea.blaze.base.scope.scopes.IdeaLogScope) ExperimentScope(com.google.idea.blaze.base.experiments.ExperimentScope) IssuesScope(com.google.idea.blaze.base.scope.scopes.IssuesScope)

Example 9 with IssuesScope

use of com.google.idea.blaze.base.scope.scopes.IssuesScope 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

IssuesScope (com.google.idea.blaze.base.scope.scopes.IssuesScope)9 IssueOutputFilter (com.google.idea.blaze.base.issueparser.IssueOutputFilter)8 BlazeContext (com.google.idea.blaze.base.scope.BlazeContext)7 WorkspaceRoot (com.google.idea.blaze.base.model.primitives.WorkspaceRoot)6 IdeaLogScope (com.google.idea.blaze.base.scope.scopes.IdeaLogScope)6 ExperimentScope (com.google.idea.blaze.base.experiments.ExperimentScope)5 BlazeCommand (com.google.idea.blaze.base.command.BlazeCommand)4 ProjectViewSet (com.google.idea.blaze.base.projectview.ProjectViewSet)4 BlazeConsoleScope (com.google.idea.blaze.base.scope.scopes.BlazeConsoleScope)4 Project (com.intellij.openapi.project.Project)4 ImmutableList (com.google.common.collect.ImmutableList)3 LineProcessingOutputStream (com.google.idea.blaze.base.async.process.LineProcessingOutputStream)3 BlazeProjectData (com.google.idea.blaze.base.model.BlazeProjectData)3 BlazeConsolePopupBehavior (com.google.idea.blaze.base.settings.BlazeUserSettings.BlazeConsolePopupBehavior)3 BuildResult (com.google.idea.blaze.base.sync.aspects.BuildResult)3 BuildResultHelper (com.google.idea.blaze.base.command.buildresult.BuildResultHelper)2 BlazeTargetFilter (com.google.idea.blaze.base.run.filter.BlazeTargetFilter)2 LineProcessingProcessAdapter (com.google.idea.blaze.base.run.processhandler.LineProcessingProcessAdapter)2 ScopedBlazeProcessHandler (com.google.idea.blaze.base.run.processhandler.ScopedBlazeProcessHandler)2 BlazeTestUiSession (com.google.idea.blaze.base.run.smrunner.BlazeTestUiSession)2