use of com.google.idea.blaze.base.model.primitives.TargetExpression in project intellij by bazelbuild.
the class BlazeRunConfigurationSyncListener method onSyncComplete.
@Override
public void onSyncComplete(Project project, BlazeContext context, BlazeImportSettings importSettings, ProjectViewSet projectViewSet, BlazeProjectData blazeProjectData, SyncMode syncMode, SyncResult syncResult) {
updateExistingRunConfigurations(project);
if (syncMode == SyncMode.STARTUP) {
return;
}
Set<File> xmlFiles = getImportedRunConfigurations(projectViewSet, blazeProjectData.workspacePathResolver);
Transactions.submitTransactionAndWait(() -> {
// First, import from specified XML files. Then auto-generate from targets.
xmlFiles.forEach((file) -> RunConfigurationSerializer.loadFromXmlIgnoreExisting(project, file));
Set<Label> labelsWithConfigs = labelsWithConfigs(project);
Set<TargetExpression> targetExpressions = Sets.newLinkedHashSet(projectViewSet.listItems(TargetSection.KEY));
// We only auto-generate configurations for rules listed in the project view.
for (TargetExpression target : targetExpressions) {
if (!(target instanceof Label) || labelsWithConfigs.contains(target)) {
continue;
}
Label label = (Label) target;
labelsWithConfigs.add(label);
maybeAddRunConfiguration(project, blazeProjectData, label);
}
});
}
use of com.google.idea.blaze.base.model.primitives.TargetExpression in project intellij by bazelbuild.
the class BlazeCidrLauncher method createDebugProcess.
@Override
public CidrDebugProcess createDebugProcess(CommandLineState state, XDebugSession session) throws ExecutionException {
TargetExpression target = configuration.getTarget();
if (target == null) {
throw new ExecutionException("Cannot parse run configuration target.");
}
if (runner.executableToDebug == null) {
throw new ExecutionException("No debug binary found.");
}
WorkspaceRoot workspaceRoot = WorkspaceRoot.fromProject(project);
GeneralCommandLine commandLine = new GeneralCommandLine(runner.executableToDebug.getPath());
File workingDir = workspaceRoot.directory();
commandLine.setWorkDirectory(workingDir);
commandLine.addParameters(handlerState.getExeFlagsState().getExpandedFlags());
EnvironmentVariablesData envState = handlerState.getEnvVarsState().getData();
commandLine.withParentEnvironmentType(envState.isPassParentEnvs() ? ParentEnvironmentType.SYSTEM : ParentEnvironmentType.NONE);
commandLine.getEnvironment().putAll(envState.getEnvs());
if (Kind.CC_TEST.equals(configuration.getTargetKind())) {
convertBlazeTestFilterToExecutableFlag().ifPresent(commandLine::addParameters);
}
TrivialInstaller installer = new TrivialInstaller(commandLine);
ImmutableList<String> startupCommands = getGdbStartupCommands(workingDir);
CLionRunParameters parameters = new CLionRunParameters(new BlazeGDBDriverConfiguration(project, startupCommands, workspaceRoot), installer);
state.setConsoleBuilder(createConsoleBuilder(null));
state.addConsoleFilters(getConsoleFilters().toArray(new Filter[0]));
return new CidrLocalDebugProcess(parameters, session, state.getConsoleBuilder());
}
use of com.google.idea.blaze.base.model.primitives.TargetExpression in project intellij by bazelbuild.
the class BlazeCommandRunConfigurationGenericHandlerIntegrationTest method testEditorApplyToAndResetFromHandlesNulls.
@Test
public void testEditorApplyToAndResetFromHandlesNulls() throws ConfigurationException {
BlazeCommandRunConfigurationSettingsEditor editor = new BlazeCommandRunConfigurationSettingsEditor(configuration);
// Call setTarget to initialize a generic handler, or this won't apply anything.
configuration.setTarget(null);
assertThat(configuration.getTarget()).isNull();
assertThat(configuration.getHandler()).isInstanceOf(BlazeCommandGenericRunConfigurationHandler.class);
BlazeCommandRunConfigurationCommonState state = (BlazeCommandRunConfigurationCommonState) configuration.getHandler().getState();
editor.resetFrom(configuration);
BlazeCommandRunConfiguration readConfiguration = type.getFactory().createTemplateConfiguration(getProject());
TargetExpression targetExpression = TargetExpression.fromStringSafe("//...");
readConfiguration.setTarget(targetExpression);
BlazeCommandRunConfigurationCommonState readState = (BlazeCommandRunConfigurationCommonState) readConfiguration.getHandler().getState();
readState.getCommandState().setCommand(COMMAND);
readState.getBlazeFlagsState().setRawFlags(ImmutableList.of("--flag1", "--flag2"));
readState.getExeFlagsState().setRawFlags(ImmutableList.of("--exeFlag1"));
readState.getBlazeBinaryState().setBlazeBinary("/usr/bin/blaze");
editor.applyEditorTo(readConfiguration);
assertThat(readConfiguration.getTarget()).isNull();
assertThat(configuration.getHandler()).isInstanceOf(BlazeCommandGenericRunConfigurationHandler.class);
readState = (BlazeCommandRunConfigurationCommonState) readConfiguration.getHandler().getState();
assertThat(readState.getCommandState().getCommand()).isEqualTo(state.getCommandState().getCommand());
assertThat(readState.getBlazeFlagsState().getRawFlags()).isEqualTo(state.getBlazeFlagsState().getRawFlags());
assertThat(readState.getExeFlagsState().getRawFlags()).isEqualTo(state.getExeFlagsState().getRawFlags());
assertThat(readState.getBlazeBinaryState().getBlazeBinary()).isEqualTo(state.getBlazeBinaryState().getBlazeBinary());
Disposer.dispose(editor);
}
use of com.google.idea.blaze.base.model.primitives.TargetExpression in project intellij by bazelbuild.
the class BlazeCommandRunConfigurationGenericHandlerIntegrationTest method testEditorApplyToAndResetFromMatches.
@Test
public void testEditorApplyToAndResetFromMatches() throws ConfigurationException {
BlazeCommandRunConfigurationSettingsEditor editor = new BlazeCommandRunConfigurationSettingsEditor(configuration);
TargetExpression targetExpression = TargetExpression.fromStringSafe("//...");
configuration.setTarget(targetExpression);
BlazeCommandRunConfigurationCommonState state = (BlazeCommandRunConfigurationCommonState) configuration.getHandler().getState();
state.getCommandState().setCommand(COMMAND);
state.getBlazeFlagsState().setRawFlags(ImmutableList.of("--flag1", "--flag2"));
state.getExeFlagsState().setRawFlags(ImmutableList.of("--exeFlag1"));
state.getBlazeBinaryState().setBlazeBinary("/usr/bin/blaze");
editor.resetFrom(configuration);
BlazeCommandRunConfiguration readConfiguration = type.getFactory().createTemplateConfiguration(getProject());
editor.applyEditorTo(readConfiguration);
assertThat(readConfiguration.getTarget()).isEqualTo(targetExpression);
assertThat(readConfiguration.getHandler()).isInstanceOf(BlazeCommandGenericRunConfigurationHandler.class);
BlazeCommandRunConfigurationCommonState readState = (BlazeCommandRunConfigurationCommonState) readConfiguration.getHandler().getState();
assertThat(readState.getCommandState().getCommand()).isEqualTo(state.getCommandState().getCommand());
assertThat(readState.getBlazeFlagsState().getRawFlags()).isEqualTo(state.getBlazeFlagsState().getRawFlags());
assertThat(readState.getExeFlagsState().getRawFlags()).isEqualTo(state.getExeFlagsState().getRawFlags());
assertThat(readState.getBlazeBinaryState().getBlazeBinary()).isEqualTo(state.getBlazeBinaryState().getBlazeBinary());
Disposer.dispose(editor);
}
use of com.google.idea.blaze.base.model.primitives.TargetExpression in project intellij by bazelbuild.
the class BlazeCommandRunConfigurationGenericHandlerIntegrationTest method testReadAndWriteMatches.
@Test
public void testReadAndWriteMatches() throws Exception {
TargetExpression targetExpression = TargetExpression.fromStringSafe("//...");
configuration.setTarget(targetExpression);
BlazeCommandRunConfigurationCommonState state = (BlazeCommandRunConfigurationCommonState) configuration.getHandler().getState();
state.getCommandState().setCommand(COMMAND);
state.getBlazeFlagsState().setRawFlags(ImmutableList.of("--flag1", "--flag2"));
state.getExeFlagsState().setRawFlags(ImmutableList.of("--exeFlag1"));
state.getBlazeBinaryState().setBlazeBinary("/usr/bin/blaze");
Element element = new Element("test");
configuration.writeExternal(element);
BlazeCommandRunConfiguration readConfiguration = type.getFactory().createTemplateConfiguration(getProject());
readConfiguration.readExternal(element);
assertThat(readConfiguration.getTarget()).isEqualTo(targetExpression);
assertThat(readConfiguration.getHandler()).isInstanceOf(BlazeCommandGenericRunConfigurationHandler.class);
BlazeCommandRunConfigurationCommonState readState = (BlazeCommandRunConfigurationCommonState) readConfiguration.getHandler().getState();
assertThat(readState.getCommandState().getCommand()).isEqualTo(COMMAND);
assertThat(readState.getBlazeFlagsState().getRawFlags()).containsExactly("--flag1", "--flag2").inOrder();
assertThat(readState.getExeFlagsState().getRawFlags()).containsExactly("--exeFlag1");
assertThat(readState.getBlazeBinaryState().getBlazeBinary()).isEqualTo("/usr/bin/blaze");
}
Aggregations