use of com.google.idea.blaze.base.run.state.BlazeCommandRunConfigurationCommonState in project intellij by bazelbuild.
the class BlazeKotlinRunConfigurationProducer method doIsConfigFromContext.
@Override
protected boolean doIsConfigFromContext(BlazeCommandRunConfiguration configuration, ConfigurationContext context) {
TargetIdeInfo target = getTargetIdeInfo(context);
BlazeCommandRunConfigurationCommonState handlerState = configuration.getHandlerStateIfType(BlazeCommandRunConfigurationCommonState.class);
return target != null && handlerState != null && Objects.equals(handlerState.getCommandState().getCommand(), BlazeCommandName.RUN) && configuration.getTarget() != null && Objects.equals(configuration.getTarget(), target.key.label);
}
use of com.google.idea.blaze.base.run.state.BlazeCommandRunConfigurationCommonState in project intellij by bazelbuild.
the class BlazeKotlinRunConfigurationProducer method doSetupConfigFromContext.
@Override
protected boolean doSetupConfigFromContext(BlazeCommandRunConfiguration configuration, ConfigurationContext context, Ref<PsiElement> sourceElement) {
Location<?> location = context.getLocation();
if (location == null) {
return false;
}
sourceElement.set(location.getPsiElement());
TargetIdeInfo target = getTargetIdeInfo(context);
if (target == null) {
return false;
}
BlazeCommandRunConfigurationCommonState handlerState = configuration.getHandlerStateIfType(BlazeCommandRunConfigurationCommonState.class);
if (handlerState == null) {
return false;
}
handlerState.getCommandState().setCommand(BlazeCommandName.RUN);
configuration.setTargetInfo(target.toTargetInfo());
configuration.setGeneratedName();
return true;
}
use of com.google.idea.blaze.base.run.state.BlazeCommandRunConfigurationCommonState in project intellij by bazelbuild.
the class BlazeKotlinTestClassConfigurationProducer method doSetupConfigFromContext.
@Override
protected boolean doSetupConfigFromContext(BlazeCommandRunConfiguration configuration, ConfigurationContext context, Ref<PsiElement> sourceElement) {
TestLocation testLocation = TestLocation.from(context);
if (testLocation == null) {
return false;
}
sourceElement.set(testLocation.getSourceElement());
TargetInfo targetInfo = testLocation.getTargetInfo();
if (targetInfo == null) {
return false;
}
configuration.setTargetInfo(targetInfo);
BlazeCommandRunConfigurationCommonState handlerState = configuration.getHandlerStateIfType(BlazeCommandRunConfigurationCommonState.class);
if (handlerState == null) {
return false;
}
handlerState.getCommandState().setCommand(BlazeCommandName.TEST);
String testFilter = testLocation.getTestFilterFlag();
if (testFilter != null) {
List<String> flags = new ArrayList<>(handlerState.getBlazeFlagsState().getRawFlags());
flags.removeIf((flag) -> flag.startsWith(BlazeFlags.TEST_FILTER));
flags.add(testFilter);
handlerState.getBlazeFlagsState().setRawFlags(flags);
}
BlazeConfigurationNameBuilder nameBuilder = new BlazeConfigurationNameBuilder(configuration);
nameBuilder.setTargetString(testLocation.getDisplayName());
configuration.setName(nameBuilder.build());
configuration.setNameChangedByUser(true);
return true;
}
use of com.google.idea.blaze.base.run.state.BlazeCommandRunConfigurationCommonState in project intellij by bazelbuild.
the class BlazeScalaSpecs2TestExprConfigurationProducer method doIsConfigFromContext.
@Override
protected boolean doIsConfigFromContext(BlazeCommandRunConfiguration configuration, ConfigurationContext context) {
BlazeCommandRunConfigurationCommonState handlerState = configuration.getHandlerStateIfType(BlazeCommandRunConfigurationCommonState.class);
if (handlerState == null || !Objects.equals(handlerState.getCommandState().getCommand(), BlazeCommandName.TEST)) {
return false;
}
TestLocation testLocation = testLocation(context);
return testLocation != null && Objects.equals(testLocation.target.label, configuration.getTarget()) && Objects.equals(testLocation.testFilter(), handlerState.getTestFilterFlag());
}
use of com.google.idea.blaze.base.run.state.BlazeCommandRunConfigurationCommonState in project intellij by bazelbuild.
the class BlazeScalaSpecs2TestExprConfigurationProducer method doSetupConfigFromContext.
@Override
protected boolean doSetupConfigFromContext(BlazeCommandRunConfiguration configuration, ConfigurationContext context, Ref<PsiElement> sourceElement) {
TestLocation testLocation = testLocation(context);
if (testLocation == null) {
return false;
}
configuration.setTargetInfo(testLocation.target);
BlazeCommandRunConfigurationCommonState handlerState = configuration.getHandlerStateIfType(BlazeCommandRunConfigurationCommonState.class);
if (handlerState == null) {
return false;
}
sourceElement.set(testLocation.testCase);
handlerState.getCommandState().setCommand(BlazeCommandName.TEST);
// remove old test filter flag if present
List<String> flags = new ArrayList<>(handlerState.getBlazeFlagsState().getRawFlags());
flags.removeIf((flag) -> flag.startsWith(BlazeFlags.TEST_FILTER));
String filter = testLocation.testFilter();
if (filter != null) {
flags.add(filter);
}
handlerState.getBlazeFlagsState().setRawFlags(flags);
String name = new BlazeConfigurationNameBuilder(configuration).setTargetString(testLocation.targetString()).build();
configuration.setName(name);
// don't revert to generated name
configuration.setNameChangedByUser(true);
return true;
}
Aggregations