Project in ExecutionEnvironment is @NotNull; remove some redundant usages of Executor

This commit is contained in:
Dmitry Jemerov
2013-07-24 19:03:03 +02:00
parent 83ed95fb57
commit 54ffbdc3c7
12 changed files with 56 additions and 31 deletions
@@ -96,7 +96,7 @@ public class DefaultJavaProgramRunner extends JavaPatchableProgramRunner {
onProcessStarted(env.getRunnerSettings(), executionResult);
final RunContentBuilder contentBuilder = new RunContentBuilder(project, this, env.getExecutor(), executionResult, env);
final RunContentBuilder contentBuilder = new RunContentBuilder(this, executionResult, env);
Disposer.register(project, contentBuilder);
if (shouldAddDefaultActions) {
addDefaultActions(contentBuilder);
@@ -17,7 +17,6 @@ package com.intellij.openapi.externalSystem.service.execution;
import com.intellij.execution.ExecutionException;
import com.intellij.execution.ExecutionResult;
import com.intellij.execution.Executor;
import com.intellij.execution.configurations.RunProfile;
import com.intellij.execution.configurations.RunProfileState;
import com.intellij.execution.executors.DefaultRunExecutor;
@@ -57,7 +56,7 @@ public class ExternalSystemTaskRunner extends GenericProgramRunner {
ExecutionResult executionResult = state.execute(env.getExecutor(), this);
if (executionResult == null) return null;
final RunContentBuilder contentBuilder = new RunContentBuilder(project, this, env.getExecutor(), executionResult, env);
final RunContentBuilder contentBuilder = new RunContentBuilder(this, executionResult, env);
return contentBuilder.showRunContent(contentToReuse);
}
}
@@ -43,12 +43,19 @@ public abstract class ExecutionManager {
public abstract ProcessHandler[] getRunningProcesses();
/**
* @deprecated use {@link #startRunProfile(RunProfileStarter, com.intellij.execution.configurations.RunProfileState, com.intellij.execution.runners.ExecutionEnvironment)}
*/
public abstract void startRunProfile(@NotNull RunProfileStarter starter,
@NotNull RunProfileState state,
@NotNull Project project,
@NotNull Executor executor,
@NotNull ExecutionEnvironment env);
public abstract void startRunProfile(@NotNull RunProfileStarter starter,
@NotNull RunProfileState state,
@NotNull ExecutionEnvironment env);
public abstract void restartRunProfile(@NotNull Project project,
@NotNull Executor executor,
@NotNull ExecutionTarget target,
@@ -62,9 +69,7 @@ public abstract class ExecutionManager {
@Nullable RunnerAndConfigurationSettings configuration,
@Nullable RunContentDescriptor currentDescriptor);
public abstract void restartRunProfile(@NotNull Project project,
@NotNull Executor executor,
@Nullable ProgramRunner runner,
public abstract void restartRunProfile(@Nullable ProgramRunner runner,
@NotNull ExecutionEnvironment environment,
@Nullable RunContentDescriptor currentDescriptor);
}
@@ -39,7 +39,7 @@ import java.util.concurrent.atomic.AtomicLong;
public class ExecutionEnvironment extends UserDataHolderBase {
private static final AtomicLong myIdHolder = new AtomicLong(1L);
@Nullable private final Project myProject;
@NotNull private final Project myProject;
@NotNull private RunProfile myRunProfile;
@NotNull private final Executor myExecutor;
@@ -63,7 +63,7 @@ public class ExecutionEnvironment extends UserDataHolderBase {
public ExecutionEnvironment(@NotNull Executor executor,
@NotNull final ProgramRunner runner,
@NotNull final RunnerAndConfigurationSettings configuration,
@Nullable Project project) {
@NotNull Project project) {
this(configuration.getConfiguration(),
executor,
DefaultExecutionTarget.INSTANCE,
@@ -83,7 +83,7 @@ public class ExecutionEnvironment extends UserDataHolderBase {
@NotNull final ProgramRunner runner,
@NotNull final ExecutionTarget target,
@NotNull final RunnerAndConfigurationSettings configuration,
Project project) {
@NotNull Project project) {
this(configuration.getConfiguration(),
executor,
target,
@@ -99,7 +99,7 @@ public class ExecutionEnvironment extends UserDataHolderBase {
*/
public ExecutionEnvironment(@NotNull RunProfile runProfile,
@NotNull Executor executor,
@Nullable Project project,
@NotNull Project project,
@Nullable RunnerSettings runnerSettings) {
this(runProfile, executor, DefaultExecutionTarget.INSTANCE, project, runnerSettings, null, null, null, null);
}
@@ -132,7 +132,7 @@ public class ExecutionEnvironment extends UserDataHolderBase {
}
}
@Nullable
@NotNull
public Project getProject() {
return myProject;
}
@@ -75,7 +75,7 @@ public final class ExecutionEnvironmentBuilder {
return this;
}
public ExecutionEnvironmentBuilder setProject(@Nullable Project project) {
public ExecutionEnvironmentBuilder setProject(@NotNull Project project) {
check(myProject, "Project");
myProject = project;
return this;
@@ -66,9 +66,6 @@ public abstract class GenericProgramRunner<Settings extends RunnerSettings> impl
throws ExecutionException {
final Project project = env.getProject();
if (project == null) {
return;
}
final RunProfileState state = env.getState();
if (state == null) {
@@ -91,7 +88,7 @@ public abstract class GenericProgramRunner<Settings extends RunnerSettings> impl
if (callback != null) callback.processStarted(descriptor);
return descriptor;
}
}, state, project, env.getExecutor(), env);
}, state, env);
}
@Nullable
@@ -47,11 +47,18 @@ public interface RunContentManager {
@Nullable
RunContentDescriptor getReuseContent(Executor requestor, @Nullable RunContentDescriptor contentToReuse);
/**
* @deprecated use {@link #getReuseContent(ExecutionEnvironment)}
*/
@Deprecated
@Nullable
RunContentDescriptor getReuseContent(Executor requestor, @NotNull ExecutionEnvironment executionEnvironment);
@Nullable
RunContentDescriptor getReuseContent(@NotNull ExecutionEnvironment executionEnvironment);
/**
* @deprecated use {@link #getReuseContent(com.intellij.execution.Executor, ExecutionEnvironment)}
* @deprecated use {@link #getReuseContent(ExecutionEnvironment)}
*/
@Deprecated
@Nullable
@@ -183,7 +183,7 @@ public class ExecutionManagerImpl extends ExecutionManager implements ProjectCom
public void startRunProfile(@NotNull final RunProfileStarter starter, @NotNull final RunProfileState state,
@NotNull final Project project, @NotNull final Executor executor, @NotNull final ExecutionEnvironment env) {
final RunContentDescriptor reuseContent =
ExecutionManager.getInstance(project).getContentManager().getReuseContent(executor, env);
ExecutionManager.getInstance(project).getContentManager().getReuseContent(env);
if (reuseContent != null) {
reuseContent.setExecutionId(env.getExecutionId());
}
@@ -248,6 +248,11 @@ public class ExecutionManagerImpl extends ExecutionManager implements ProjectCom
}
}
@Override
public void startRunProfile(@NotNull RunProfileStarter starter, @NotNull RunProfileState state, @NotNull ExecutionEnvironment env) {
startRunProfile(starter, state, env.getProject(), env.getExecutor(), env);
}
@Override
public void restartRunProfile(@NotNull final Project project,
@NotNull final Executor executor,
@@ -276,17 +281,15 @@ public class ExecutionManagerImpl extends ExecutionManager implements ProjectCom
}
@Override
public void restartRunProfile(@NotNull Project project,
@NotNull Executor executor,
@Nullable ProgramRunner runner,
public void restartRunProfile(@Nullable ProgramRunner runner,
@NotNull ExecutionEnvironment environment,
@Nullable RunContentDescriptor currentDescriptor) {
restartRunProfile(project,
restartRunProfile(environment.getProject(),
runner,
environment.getRunProfile(),
environment.getRunnerSettings(),
environment.getConfigurationSettings(),
executor,
environment.getExecutor(),
environment.getExecutionTarget(),
environment.getRunnerAndConfigurationSettings(), currentDescriptor);
}
@@ -18,7 +18,6 @@ package com.intellij.execution.runners;
import com.intellij.execution.ExecutionException;
import com.intellij.execution.ExecutionResult;
import com.intellij.execution.Executor;
import com.intellij.execution.configurations.RunProfileState;
import com.intellij.execution.ui.RunContentDescriptor;
import com.intellij.openapi.fileEditor.FileDocumentManager;
@@ -38,7 +37,7 @@ public abstract class DefaultProgramRunner extends GenericProgramRunner {
ExecutionResult executionResult = state.execute(env.getExecutor(), this);
if (executionResult == null) return null;
final RunContentBuilder contentBuilder = new RunContentBuilder(project, this, env.getExecutor(), executionResult, env);
final RunContentBuilder contentBuilder = new RunContentBuilder(this, executionResult, env);
return contentBuilder.showRunContent(contentToReuse);
}
@@ -105,8 +105,8 @@ public class RestartAction extends FakeRerunAction implements DumbAware, AnActio
public void restart() {
Project project = myEnvironment.getProject();
if (project != null && !ExecutorRegistry.getInstance().isStarting(project, myExecutor.getId(), myRunner.getRunnerId()))
ExecutionManager.getInstance(project).restartRunProfile(project, myExecutor, myRunner, myEnvironment, myDescriptor);
if (!ExecutorRegistry.getInstance().isStarting(project, myExecutor.getId(), myRunner.getRunnerId()))
ExecutionManager.getInstance(project).restartRunProfile(myRunner, myEnvironment, myDescriptor);
}
@Override
@@ -60,15 +60,24 @@ public class RunContentBuilder extends LogConsoleManagerBase {
private RunnerLayoutUi myUi;
private final Executor myExecutor;
/**
* @deprecated use {@link #RunContentBuilder(ProgramRunner, com.intellij.execution.ExecutionResult, ExecutionEnvironment)}
*/
public RunContentBuilder(@NotNull Project project,
ProgramRunner runner,
Executor executor,
ExecutionResult executionResult,
@NotNull ExecutionEnvironment environment) {
super(project, createSearchScope(project, environment.getRunProfile()));
this(runner, executionResult, environment);
}
public RunContentBuilder(ProgramRunner runner,
ExecutionResult executionResult,
@NotNull ExecutionEnvironment environment) {
super(environment.getProject(), createSearchScope(environment.getProject(), environment.getRunProfile()));
myRunner = runner;
myExecutor = executor;
myManager = new LogFilesManager(project, this, this);
myExecutor = environment.getExecutor();
myManager = new LogFilesManager(environment.getProject(), this, this);
myExecutionResult = executionResult;
setEnvironment(environment);
}
@@ -392,11 +392,17 @@ public class RunContentManagerImpl implements RunContentManager, Disposable {
@Nullable
@Override
public RunContentDescriptor getReuseContent(Executor requestor, @NotNull ExecutionEnvironment executionEnvironment) {
return getReuseContent(executionEnvironment);
}
@Nullable
@Override
public RunContentDescriptor getReuseContent(@NotNull ExecutionEnvironment executionEnvironment) {
if (ApplicationManager.getApplication().isUnitTestMode()) return null;
RunContentDescriptor contentToReuse = executionEnvironment.getContentToReuse();
if (contentToReuse != null) return contentToReuse;
final ContentManager contentManager = getContentManagerForRunner(requestor);
final ContentManager contentManager = getContentManagerForRunner(executionEnvironment.getExecutor());
return chooseReuseContentForDescriptor(contentManager, contentToReuse, executionEnvironment.getExecutionId(),
executionEnvironment.toString());
}