simplify — environment is enough

This commit is contained in:
Vladimir Krivosheev
2014-08-27 16:04:14 +02:00
parent 07c08dfebb
commit 6ea5ad5663
6 changed files with 28 additions and 47 deletions
@@ -69,10 +69,7 @@ public class DefaultJavaProgramRunner extends JavaPatchableProgramRunner {
}
@Override
protected RunContentDescriptor doExecute(@NotNull final Project project,
@NotNull final RunProfileState state,
final RunContentDescriptor contentToReuse,
@NotNull final ExecutionEnvironment env) throws ExecutionException {
protected RunContentDescriptor doExecute(@NotNull final RunProfileState state, @NotNull final ExecutionEnvironment env) throws ExecutionException {
FileDocumentManager.getInstance().saveAllDocuments();
ExecutionResult executionResult;
@@ -100,11 +97,11 @@ public class DefaultJavaProgramRunner extends JavaPatchableProgramRunner {
onProcessStarted(env.getRunnerSettings(), executionResult);
final RunContentBuilder contentBuilder = new RunContentBuilder(executionResult, env);
Disposer.register(project, contentBuilder);
Disposer.register(env.getProject(), contentBuilder);
if (shouldAddDefaultActions) {
addDefaultActions(contentBuilder);
}
return contentBuilder.showRunContent(contentToReuse);
return contentBuilder.showRunContent(env.getContentToReuse());
}
@Deprecated
@@ -25,7 +25,6 @@ import com.intellij.execution.runners.GenericProgramRunner;
import com.intellij.execution.runners.RunContentBuilder;
import com.intellij.execution.ui.RunContentDescriptor;
import com.intellij.openapi.externalSystem.util.ExternalSystemConstants;
import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -48,11 +47,8 @@ public class ExternalSystemTaskRunner extends GenericProgramRunner {
@Nullable
@Override
protected RunContentDescriptor doExecute(@NotNull Project project,
@NotNull RunProfileState state,
RunContentDescriptor contentToReuse,
@NotNull ExecutionEnvironment env) throws ExecutionException {
protected RunContentDescriptor doExecute(@NotNull RunProfileState state, @NotNull ExecutionEnvironment env) throws ExecutionException {
ExecutionResult executionResult = state.execute(env.getExecutor(), this);
return executionResult == null ? null : new RunContentBuilder(executionResult, env).showRunContent(contentToReuse);
return executionResult == null ? null : new RunContentBuilder(executionResult, env).showRunContent(env.getContentToReuse());
}
}
@@ -40,15 +40,25 @@ public abstract class GenericProgramRunner<Settings extends RunnerSettings> exte
ExecutionManager.getInstance(environment.getProject()).startRunProfile(new RunProfileStarter() {
@Override
public RunContentDescriptor execute(@NotNull RunProfileState state, @NotNull ExecutionEnvironment environment) throws ExecutionException {
return postProcess(environment, doExecute(environment.getProject(), state, environment.getContentToReuse(), environment), callback);
return postProcess(environment, doExecute(state, environment), callback);
}
}, state, environment);
}
@Nullable
protected abstract RunContentDescriptor doExecute(@NotNull Project project,
@NotNull RunProfileState state,
@Nullable RunContentDescriptor contentToReuse,
@NotNull ExecutionEnvironment environment) throws ExecutionException;
protected RunContentDescriptor doExecute(@NotNull RunProfileState state, @NotNull ExecutionEnvironment environment) throws ExecutionException {
return doExecute(environment.getProject(), state, environment.getContentToReuse(), environment);
}
@Deprecated
@Nullable
/**
* @deprecated to remove in IDEA 16
*/
protected RunContentDescriptor doExecute(@NotNull Project project,
@NotNull RunProfileState state,
@Nullable RunContentDescriptor contentToReuse,
@NotNull ExecutionEnvironment environment) throws ExecutionException {
throw new AbstractMethodError();
}
}
@@ -21,25 +21,19 @@ import com.intellij.execution.ExecutionResult;
import com.intellij.execution.configurations.RunProfileState;
import com.intellij.execution.ui.RunContentDescriptor;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.NotNull;
/**
* @author spleaner
*/
public abstract class DefaultProgramRunner extends GenericProgramRunner {
@Override
protected RunContentDescriptor doExecute(@NotNull final Project project,
@NotNull final RunProfileState state,
final RunContentDescriptor contentToReuse,
@NotNull final ExecutionEnvironment env) throws ExecutionException {
protected RunContentDescriptor doExecute(@NotNull RunProfileState state, @NotNull ExecutionEnvironment env) throws ExecutionException {
FileDocumentManager.getInstance().saveAllDocuments();
ExecutionResult executionResult = state.execute(env.getExecutor(), this);
if (executionResult == null) {
return null;
}
return new RunContentBuilder(executionResult, env).showRunContent(contentToReuse);
return new RunContentBuilder(executionResult, env).showRunContent(env.getContentToReuse());
}
}
@@ -23,7 +23,6 @@ import com.intellij.execution.runners.ExecutionEnvironment;
import com.intellij.execution.runners.GenericProgramRunner;
import com.intellij.execution.ui.RunContentDescriptor;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -32,10 +31,7 @@ public class AntRunner extends GenericProgramRunner {
@Nullable
@Override
protected RunContentDescriptor doExecute(@NotNull Project project,
@NotNull RunProfileState state,
@Nullable RunContentDescriptor contentToReuse,
@NotNull ExecutionEnvironment environment) throws ExecutionException {
protected RunContentDescriptor doExecute(@NotNull RunProfileState state, @NotNull ExecutionEnvironment environment) throws ExecutionException {
FileDocumentManager.getInstance().saveAllDocuments();
state.execute(environment.getExecutor(), this);
return null;
@@ -8,7 +8,6 @@ import com.intellij.execution.runners.DefaultProgramRunner;
import com.intellij.execution.runners.ExecutionEnvironment;
import com.intellij.execution.ui.RunContentDescriptor;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.project.Project;
import com.intellij.xdebugger.XDebugProcess;
import com.intellij.xdebugger.XDebugProcessStarter;
import com.intellij.xdebugger.XDebugSession;
@@ -19,11 +18,6 @@ import org.intellij.plugins.xsltDebugger.impl.XsltDebugProcess;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
/*
* Created by IntelliJ IDEA.
* User: sweinreuter
* Date: 16.11.10
*/
public class XsltDebuggerRunner extends DefaultProgramRunner {
static final ThreadLocal<Boolean> ACTIVE = new ThreadLocal<Boolean>();
@@ -43,26 +37,20 @@ public class XsltDebuggerRunner extends DefaultProgramRunner {
}
@Override
protected RunContentDescriptor doExecute(@NotNull Project project,
@NotNull RunProfileState state,
RunContentDescriptor contentToReuse,
@NotNull ExecutionEnvironment env) throws ExecutionException {
protected RunContentDescriptor doExecute(@NotNull RunProfileState state, @NotNull ExecutionEnvironment env) throws ExecutionException {
FileDocumentManager.getInstance().saveAllDocuments();
return createContentDescriptor(project, state, contentToReuse, env);
return createContentDescriptor(state, env);
}
protected RunContentDescriptor createContentDescriptor(Project project,
final RunProfileState runProfileState,
RunContentDescriptor contentToReuse,
final ExecutionEnvironment executionEnvironment) throws ExecutionException {
protected RunContentDescriptor createContentDescriptor(final RunProfileState runProfileState, final ExecutionEnvironment environment) throws ExecutionException {
final XDebugSession debugSession =
XDebuggerManager.getInstance(project).startSession(this, executionEnvironment, contentToReuse, new XDebugProcessStarter() {
XDebuggerManager.getInstance(environment.getProject()).startSession(environment, new XDebugProcessStarter() {
@NotNull
public XDebugProcess start(@NotNull final XDebugSession session) throws ExecutionException {
ACTIVE.set(Boolean.TRUE);
try {
final XsltCommandLineState c = (XsltCommandLineState)runProfileState;
final ExecutionResult result = runProfileState.execute(executionEnvironment.getExecutor(), XsltDebuggerRunner.this);
final ExecutionResult result = runProfileState.execute(environment.getExecutor(), XsltDebuggerRunner.this);
return new XsltDebugProcess(session, result, c.getExtensionData().getUserData(XsltDebuggerExtension.VERSION));
} finally {
ACTIVE.remove();