Search in sources :

Example 1 with AbstractPythonRunConfigurationParams

use of com.jetbrains.python.run.AbstractPythonRunConfigurationParams in project intellij-community by JetBrains.

the class ConfigurationBasedProcessRunner method createExecutionEnvironment.

@NotNull
private ExecutionEnvironment createExecutionEnvironment(@NotNull final String sdkPath, @NotNull final Project project, @NotNull final String workingDir) throws ExecutionException {
    final RunnerAndConfigurationSettings settings = RunManager.getInstance(project).createRunConfiguration("test", myConfigurationFactory);
    final AbstractPythonRunConfigurationParams config = (AbstractPythonRunConfigurationParams) settings.getConfiguration();
    assert myExpectedConfigurationType.isInstance(config) : String.format("Expected configuration %s, but got %s", myExpectedConfigurationType, config.getClass());
    // Checked by assert
    @SuppressWarnings("unchecked") final CONF_T castedConfiguration = (CONF_T) config;
    castedConfiguration.setSdkHome(sdkPath);
    castedConfiguration.setWorkingDirectory(workingDir);
    new WriteAction() {

        @Override
        protected void run(@NotNull final Result result) throws Throwable {
            configurationCreatedAndWillLaunch(castedConfiguration);
            RunManagerEx.getInstanceEx(project).addConfiguration(settings, false);
            RunManagerEx.getInstanceEx(project).setSelectedConfiguration(settings);
            Assert.assertSame(settings, RunManagerEx.getInstanceEx(project).getSelectedConfiguration());
        }
    }.execute();
    // Execute
    final Executor executor = DefaultRunExecutor.getRunExecutorInstance();
    return ExecutionEnvironmentBuilder.create(executor, settings).build();
}
Also used : DefaultRunExecutor(com.intellij.execution.executors.DefaultRunExecutor) WriteAction(com.intellij.openapi.application.WriteAction) AbstractPythonRunConfigurationParams(com.jetbrains.python.run.AbstractPythonRunConfigurationParams) Result(com.intellij.openapi.application.Result) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

DefaultRunExecutor (com.intellij.execution.executors.DefaultRunExecutor)1 Result (com.intellij.openapi.application.Result)1 WriteAction (com.intellij.openapi.application.WriteAction)1 AbstractPythonRunConfigurationParams (com.jetbrains.python.run.AbstractPythonRunConfigurationParams)1 NotNull (org.jetbrains.annotations.NotNull)1