Search in sources :

Example 1 with BlazeCommandName

use of com.google.idea.blaze.base.command.BlazeCommandName in project intellij by bazelbuild.

the class CoverageUtils method isApplicableTo.

public static boolean isApplicableTo(RunProfile runProfile) {
    BlazeCommandRunConfiguration config = toBlazeConfig(runProfile);
    if (config == null) {
        return false;
    }
    if (Blaze.getBuildSystem(config.getProject()) != BuildSystem.Blaze) {
        // file locations
        return false;
    }
    BlazeCommandRunConfigurationCommonState handlerState = config.getHandlerStateIfType(BlazeCommandRunConfigurationCommonState.class);
    if (handlerState == null) {
        return false;
    }
    BlazeCommandName command = handlerState.getCommandState().getCommand();
    return BlazeCommandName.TEST.equals(command) || BlazeCommandName.COVERAGE.equals(command);
}
Also used : BlazeCommandRunConfigurationCommonState(com.google.idea.blaze.base.run.state.BlazeCommandRunConfigurationCommonState) BlazeCommandRunConfiguration(com.google.idea.blaze.base.run.BlazeCommandRunConfiguration) BlazeCommandName(com.google.idea.blaze.base.command.BlazeCommandName)

Example 2 with BlazeCommandName

use of com.google.idea.blaze.base.command.BlazeCommandName in project intellij by bazelbuild.

the class BlazePyDebugRunner method canRun.

@Override
public boolean canRun(String executorId, RunProfile profile) {
    if (!DefaultDebugExecutor.EXECUTOR_ID.equals(executorId) || !(profile instanceof BlazeCommandRunConfiguration)) {
        return false;
    }
    BlazeCommandRunConfiguration config = (BlazeCommandRunConfiguration) profile;
    BlazeCommandRunConfigurationCommonState handlerState = config.getHandlerStateIfType(BlazeCommandRunConfigurationCommonState.class);
    BlazeCommandName command = handlerState != null ? handlerState.getCommandState().getCommand() : null;
    return PyDebugUtils.canUsePyDebugger(config.getTargetKind()) && (BlazeCommandName.TEST.equals(command) || BlazeCommandName.RUN.equals(command));
}
Also used : BlazeCommandRunConfigurationCommonState(com.google.idea.blaze.base.run.state.BlazeCommandRunConfigurationCommonState) BlazeCommandRunConfiguration(com.google.idea.blaze.base.run.BlazeCommandRunConfiguration) BlazeCommandName(com.google.idea.blaze.base.command.BlazeCommandName)

Example 3 with BlazeCommandName

use of com.google.idea.blaze.base.command.BlazeCommandName in project intellij by bazelbuild.

the class BlazeJavaRunProfileState method getBlazeCommandBuilder.

@VisibleForTesting
static BlazeCommand.Builder getBlazeCommandBuilder(Project project, BlazeCommandRunConfiguration configuration, List<String> extraBlazeFlags, ExecutorType executorType) {
    List<String> blazeFlags = new ArrayList<>(extraBlazeFlags);
    ProjectViewSet projectViewSet = Preconditions.checkNotNull(ProjectViewManager.getInstance(project).getProjectViewSet());
    BlazeJavaRunConfigState handlerState = getState(configuration);
    String binaryPath = handlerState.getBlazeBinaryState().getBlazeBinary() != null ? handlerState.getBlazeBinaryState().getBlazeBinary() : Blaze.getBuildSystemProvider(project).getBinaryPath();
    BlazeCommandName blazeCommand = Preconditions.checkNotNull(handlerState.getCommandState().getCommand());
    if (executorType == ExecutorType.COVERAGE) {
        blazeCommand = BlazeCommandName.COVERAGE;
        blazeFlags.addAll(CoverageUtils.getBlazeFlags());
    }
    BlazeCommand.Builder command = BlazeCommand.builder(binaryPath, blazeCommand).addTargets(configuration.getTarget()).addBlazeFlags(BlazeFlags.blazeFlags(project, projectViewSet, blazeCommand, BlazeInvocationContext.NonSync)).addBlazeFlags(blazeFlags).addBlazeFlags(handlerState.getBlazeFlagsState().getExpandedFlags());
    if (executorType == ExecutorType.DEBUG) {
        Kind kind = configuration.getTargetKind();
        boolean isBinary = kind != null && kind.ruleType == RuleType.BINARY;
        int debugPort = handlerState.getDebugPortState().port;
        if (isBinary) {
            command.addExeFlags(debugPortFlag(false, debugPort));
        } else {
            command.addBlazeFlags(BlazeFlags.JAVA_TEST_DEBUG);
            command.addBlazeFlags(debugPortFlag(true, debugPort));
        }
    }
    command.addExeFlags(handlerState.getExeFlagsState().getExpandedFlags());
    return command;
}
Also used : ProjectViewSet(com.google.idea.blaze.base.projectview.ProjectViewSet) BlazeCommand(com.google.idea.blaze.base.command.BlazeCommand) Kind(com.google.idea.blaze.base.model.primitives.Kind) ArrayList(java.util.ArrayList) BlazeCommandName(com.google.idea.blaze.base.command.BlazeCommandName) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 4 with BlazeCommandName

use of com.google.idea.blaze.base.command.BlazeCommandName in project intellij by bazelbuild.

the class RunConfigurationUtils method canUseClionRunner.

static boolean canUseClionRunner(BlazeCommandRunConfiguration config) {
    Kind kind = config.getTargetKind();
    BlazeCommandRunConfigurationCommonState handlerState = config.getHandlerStateIfType(BlazeCommandRunConfigurationCommonState.class);
    if (handlerState == null) {
        return false;
    }
    BlazeCommandName command = handlerState.getCommandState().getCommand();
    return kind != null && command != null && ((kind == Kind.CC_TEST && command.equals(BlazeCommandName.TEST)) || (kind == Kind.CC_BINARY && command.equals(BlazeCommandName.RUN)));
}
Also used : BlazeCommandRunConfigurationCommonState(com.google.idea.blaze.base.run.state.BlazeCommandRunConfigurationCommonState) Kind(com.google.idea.blaze.base.model.primitives.Kind) BlazeCommandName(com.google.idea.blaze.base.command.BlazeCommandName)

Aggregations

BlazeCommandName (com.google.idea.blaze.base.command.BlazeCommandName)4 BlazeCommandRunConfigurationCommonState (com.google.idea.blaze.base.run.state.BlazeCommandRunConfigurationCommonState)3 Kind (com.google.idea.blaze.base.model.primitives.Kind)2 BlazeCommandRunConfiguration (com.google.idea.blaze.base.run.BlazeCommandRunConfiguration)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 BlazeCommand (com.google.idea.blaze.base.command.BlazeCommand)1 ProjectViewSet (com.google.idea.blaze.base.projectview.ProjectViewSet)1 ArrayList (java.util.ArrayList)1