Fix runner in execution environment after configuration editing on execution attempt.

Some configuration types can support more than single debug runner type and after editing properties of such configuration selected runner should be recalculated and environment needs to be updated.

GitOrigin-RevId: d9235093f8e71305efeb43832f53bfaab959009b
This commit is contained in:
Leonid Mashinskiy
2019-10-10 17:31:49 +00:00
committed by intellij-monorepo-bot
parent 80783d418e
commit ec6937be0b
@@ -32,7 +32,7 @@ public class ProgramRunnerUtil {
private ProgramRunnerUtil() { }
@Nullable
public static ProgramRunner getRunner(@NotNull String executorId, @Nullable RunnerAndConfigurationSettings configuration) {
public static ProgramRunner<?> getRunner(@NotNull String executorId, @Nullable RunnerAndConfigurationSettings configuration) {
return configuration == null ? null : ProgramRunner.getRunner(executorId, configuration.getConfiguration());
}
@@ -55,6 +55,8 @@ public class ProgramRunnerUtil {
RunnerAndConfigurationSettings runnerAndConfigurationSettings = environment.getRunnerAndConfigurationSettings();
final Project project = environment.getProject();
ProgramRunner<?> runner = environment.getRunner();
if (runnerAndConfigurationSettings != null) {
if (!ExecutionTargetManager.canRun(environment)) {
ExecutionUtil.handleExecutionError(environment, new ExecutionException(
@@ -79,9 +81,18 @@ public class ProgramRunnerUtil {
}
}
}
// corresponding runner can be changed after configuration edit
runner = getRunner(environment.getExecutor().getId(), runnerAndConfigurationSettings);
}
try {
if (runner == null) {
throw new ExecutionException("Cannot find runner for " + environment.getRunProfile().getName());
}
if (!runner.equals(environment.getRunner())) {
environment = new ExecutionEnvironmentBuilder(environment).runner(runner).build();
}
if (assignNewId) {
environment.assignNewExecutionId();
}