summaryrefslogtreecommitdiff
path: root/platform/lang-api/src/com/intellij/execution/runners/ExecutionEnvironment.java
diff options
context:
space:
mode:
Diffstat (limited to 'platform/lang-api/src/com/intellij/execution/runners/ExecutionEnvironment.java')
-rw-r--r--platform/lang-api/src/com/intellij/execution/runners/ExecutionEnvironment.java80
1 files changed, 49 insertions, 31 deletions
diff --git a/platform/lang-api/src/com/intellij/execution/runners/ExecutionEnvironment.java b/platform/lang-api/src/com/intellij/execution/runners/ExecutionEnvironment.java
index 6acc467249e3..e85e36669f2c 100644
--- a/platform/lang-api/src/com/intellij/execution/runners/ExecutionEnvironment.java
+++ b/platform/lang-api/src/com/intellij/execution/runners/ExecutionEnvironment.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.intellij.execution.runners;
import com.intellij.execution.*;
@@ -39,9 +38,7 @@ import java.util.concurrent.atomic.AtomicLong;
import static com.intellij.openapi.actionSystem.LangDataKeys.*;
-
-public class ExecutionEnvironment extends UserDataHolderBase {
-
+public class ExecutionEnvironment extends UserDataHolderBase implements Disposable {
private static final AtomicLong myIdHolder = new AtomicLong(1L);
@NotNull private final Project myProject;
@@ -54,7 +51,7 @@ public class ExecutionEnvironment extends UserDataHolderBase {
@Nullable private ConfigurationPerRunnerSettings myConfigurationSettings;
@Nullable private final RunnerAndConfigurationSettings myRunnerAndConfigurationSettings;
@Nullable private RunContentDescriptor myContentToReuse;
- @Nullable private String myRunnerId;
+ private final ProgramRunner<?> myRunner;
private long myExecutionId = 0;
@Nullable private DataContext myDataContext;
@@ -64,11 +61,12 @@ public class ExecutionEnvironment extends UserDataHolderBase {
myContentToReuse = null;
myRunnerAndConfigurationSettings = null;
myExecutor = null;
+ myRunner = null;
}
public ExecutionEnvironment(@NotNull Executor executor,
- @NotNull final ProgramRunner runner,
- @NotNull final RunnerAndConfigurationSettings configuration,
+ @NotNull ProgramRunner runner,
+ @NotNull RunnerAndConfigurationSettings configuration,
@NotNull Project project) {
this(configuration.getConfiguration(),
executor,
@@ -78,11 +76,12 @@ public class ExecutionEnvironment extends UserDataHolderBase {
configuration.getConfigurationSettings(runner),
null,
null,
- runner.getRunnerId());
+ runner);
}
/**
* @deprecated, use {@link com.intellij.execution.runners.ExecutionEnvironmentBuilder} instead
+ * to remove in IDEA 14
*/
@TestOnly
public ExecutionEnvironment(@NotNull Executor executor,
@@ -97,45 +96,46 @@ public class ExecutionEnvironment extends UserDataHolderBase {
configuration.getRunnerSettings(runner),
configuration.getConfigurationSettings(runner),
null,
- configuration, runner.getRunnerId());
+ configuration,
+ runner);
}
/**
* @deprecated, use {@link com.intellij.execution.runners.ExecutionEnvironmentBuilder} instead
+ * to remove in IDEA 15
*/
public ExecutionEnvironment(@NotNull RunProfile runProfile,
@NotNull Executor executor,
@NotNull Project project,
@Nullable RunnerSettings runnerSettings) {
- this(runProfile, executor, DefaultExecutionTarget.INSTANCE, project, runnerSettings, null, null, null, null);
+ //noinspection ConstantConditions
+ this(runProfile, executor, DefaultExecutionTarget.INSTANCE, project, runnerSettings, null, null, null, RunnerRegistry.getInstance().getRunner(executor.getId(), runProfile));
}
- public ExecutionEnvironment(@NotNull RunProfile runProfile,
- @NotNull Executor executor,
- @NotNull ExecutionTarget target,
- @NotNull Project project,
- @Nullable RunnerSettings runnerSettings,
- @Nullable ConfigurationPerRunnerSettings configurationSettings,
- @Nullable RunContentDescriptor contentToReuse,
- @Nullable RunnerAndConfigurationSettings settings,
- @Nullable String runnerId) {
+ ExecutionEnvironment(@NotNull RunProfile runProfile,
+ @NotNull Executor executor,
+ @NotNull ExecutionTarget target,
+ @NotNull Project project,
+ @Nullable RunnerSettings runnerSettings,
+ @Nullable ConfigurationPerRunnerSettings configurationSettings,
+ @Nullable RunContentDescriptor contentToReuse,
+ @Nullable RunnerAndConfigurationSettings settings,
+ @NotNull ProgramRunner<?> runner) {
myExecutor = executor;
myTarget = target;
myRunProfile = runProfile;
myRunnerSettings = runnerSettings;
myConfigurationSettings = configurationSettings;
myProject = project;
- myContentToReuse = contentToReuse;
+ setContentToReuse(contentToReuse);
myRunnerAndConfigurationSettings = settings;
- myRunnerId = runnerId;
- if (myContentToReuse != null) {
- Disposer.register(myContentToReuse, new Disposable() {
- @Override
- public void dispose() {
- myContentToReuse = null;
- }
- });
- }
+
+ myRunner = runner;
+ }
+
+ @Override
+ public void dispose() {
+ myContentToReuse = null;
}
@NotNull
@@ -163,9 +163,27 @@ public class ExecutionEnvironment extends UserDataHolderBase {
return myContentToReuse;
}
+ public void setContentToReuse(@Nullable RunContentDescriptor contentToReuse) {
+ myContentToReuse = contentToReuse;
+
+ if (contentToReuse != null) {
+ Disposer.register(contentToReuse, this);
+ }
+ }
+
@Nullable
+ @Deprecated
+ /**
+ * Use {@link #getRunner()} instead
+ * to remove in IDEA 15
+ */
public String getRunnerId() {
- return myRunnerId;
+ return myRunner.getRunnerId();
+ }
+
+ @NotNull
+ public ProgramRunner<?> getRunner() {
+ return myRunner;
}
@Nullable