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