use of com.google.idea.blaze.base.run.state.BlazeCommandRunConfigurationCommonState in project intellij by bazelbuild.
the class BlazeGoBinaryConfigurationProducer method doIsConfigFromContext.
@Override
protected boolean doIsConfigFromContext(BlazeCommandRunConfiguration configuration, ConfigurationContext context) {
BlazeCommandRunConfigurationCommonState handlerState = configuration.getHandlerStateIfType(BlazeCommandRunConfigurationCommonState.class);
if (handlerState == null || !BlazeCommandName.RUN.equals(handlerState.getCommandState().getCommand())) {
return false;
}
PsiFile file = getMainFile(context);
if (file == null) {
return false;
}
TargetInfo binaryTarget = getTargetLabel(file);
return binaryTarget != null && binaryTarget.label.equals(configuration.getTarget());
}
use of com.google.idea.blaze.base.run.state.BlazeCommandRunConfigurationCommonState in project intellij by bazelbuild.
the class BlazeGoBinaryConfigurationProducer method doSetupConfigFromContext.
@Override
protected boolean doSetupConfigFromContext(BlazeCommandRunConfiguration configuration, ConfigurationContext context, Ref<PsiElement> sourceElement) {
PsiFile file = getMainFile(context);
if (file == null) {
return false;
}
TargetInfo binaryTarget = getTargetLabel(file);
if (binaryTarget == null) {
return false;
}
configuration.setTargetInfo(binaryTarget);
sourceElement.set(file);
BlazeCommandRunConfigurationCommonState handlerState = configuration.getHandlerStateIfType(BlazeCommandRunConfigurationCommonState.class);
if (handlerState == null) {
return false;
}
handlerState.getCommandState().setCommand(BlazeCommandName.RUN);
configuration.setGeneratedName();
return true;
}
use of com.google.idea.blaze.base.run.state.BlazeCommandRunConfigurationCommonState in project intellij by bazelbuild.
the class BlazeGoTestConfigurationProducer 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);
sourceElement.set(testLocation.sourceElement());
BlazeCommandRunConfigurationCommonState handlerState = configuration.getHandlerStateIfType(BlazeCommandRunConfigurationCommonState.class);
if (handlerState == null) {
return false;
}
handlerState.getCommandState().setCommand(BlazeCommandName.TEST);
// remove conflicting flags from initial configuration
List<String> flags = new ArrayList<>(handlerState.getBlazeFlagsState().getRawFlags());
flags.removeIf((flag) -> flag.startsWith(BlazeFlags.TEST_FILTER));
String testFilter = testLocation.testFilter();
if (testFilter != null) {
flags.add(testFilter);
}
handlerState.getBlazeFlagsState().setRawFlags(flags);
BlazeConfigurationNameBuilder nameBuilder = new BlazeConfigurationNameBuilder(configuration);
nameBuilder.setTargetString(testLocation.targetString());
configuration.setName(nameBuilder.build());
// don't revert to generated name
configuration.setNameChangedByUser(true);
return true;
}
use of com.google.idea.blaze.base.run.state.BlazeCommandRunConfigurationCommonState in project intellij by bazelbuild.
the class BlazeScalaTestClassConfigurationProducer method doIsConfigFromContext.
@Override
protected boolean doIsConfigFromContext(BlazeCommandRunConfiguration configuration, ConfigurationContext context) {
PsiClass testClass = getTestClass(context);
if (testClass == null) {
return false;
}
BlazeCommandRunConfigurationCommonState handlerState = configuration.getHandlerStateIfType(BlazeCommandRunConfigurationCommonState.class);
if (handlerState == null || !Objects.equals(handlerState.getCommandState().getCommand(), BlazeCommandName.TEST) || !Objects.equals(handlerState.getTestFilterFlag(), getTestFilterFlag(testClass))) {
return false;
}
TargetInfo target = RunUtil.targetForTestClass(testClass, TestSizeAnnotationMap.getTestSize(testClass));
return target != null && Objects.equals(configuration.getTarget(), target.label);
}
use of com.google.idea.blaze.base.run.state.BlazeCommandRunConfigurationCommonState in project intellij by bazelbuild.
the class BlazeScalaTestClassConfigurationProducer method doSetupConfigFromContext.
@Override
protected boolean doSetupConfigFromContext(BlazeCommandRunConfiguration configuration, ConfigurationContext context, Ref<PsiElement> sourceElement) {
ScClass testClass = getTestClass(context);
if (testClass == null) {
return false;
}
sourceElement.set(testClass);
TargetInfo target = RunUtil.targetForTestClass(testClass, TestSizeAnnotationMap.getTestSize(testClass));
if (target == null) {
return false;
}
configuration.setTargetInfo(target);
BlazeCommandRunConfigurationCommonState handlerState = configuration.getHandlerStateIfType(BlazeCommandRunConfigurationCommonState.class);
if (handlerState == null) {
return false;
}
List<String> flags = new ArrayList<>(handlerState.getBlazeFlagsState().getRawFlags());
flags.removeIf((flag) -> flag.startsWith(BlazeFlags.TEST_FILTER));
flags.add(getTestFilterFlag(testClass));
handlerState.getBlazeFlagsState().setRawFlags(flags);
handlerState.getCommandState().setCommand(BlazeCommandName.TEST);
BlazeConfigurationNameBuilder nameBuilder = new BlazeConfigurationNameBuilder(configuration);
nameBuilder.setTargetString(testClass.getName());
configuration.setName(nameBuilder.build());
// don't revert to generated name
configuration.setNameChangedByUser(true);
return true;
}
Aggregations