diff options
author | Tor Norbye <tnorbye@google.com> | 2014-09-04 13:24:04 -0700 |
---|---|---|
committer | Tor Norbye <tnorbye@google.com> | 2014-09-04 13:24:04 -0700 |
commit | c3d3a90f6b4ead083d63e28e6b9fcea93d675678 (patch) | |
tree | fc0dcd722b6d445468dbe7dad13b4c11781b1cbe /platform/lang-api/src/com/intellij/execution/runners/AsyncGenericProgramRunner.java | |
parent | 1aa2e09bdbd413eacb677e9fa4b50630530d0656 (diff) | |
download | idea-c3d3a90f6b4ead083d63e28e6b9fcea93d675678.tar.gz |
Snapshot idea/138.1980 from git://git.jetbrains.org/idea/community.git
Change-Id: Ib567c9c152d770212a7a3db20fbf591c210920bd
Diffstat (limited to 'platform/lang-api/src/com/intellij/execution/runners/AsyncGenericProgramRunner.java')
-rw-r--r-- | platform/lang-api/src/com/intellij/execution/runners/AsyncGenericProgramRunner.java | 41 |
1 files changed, 10 insertions, 31 deletions
diff --git a/platform/lang-api/src/com/intellij/execution/runners/AsyncGenericProgramRunner.java b/platform/lang-api/src/com/intellij/execution/runners/AsyncGenericProgramRunner.java index aeaaf58eda65..ce7145adeaf9 100644 --- a/platform/lang-api/src/com/intellij/execution/runners/AsyncGenericProgramRunner.java +++ b/platform/lang-api/src/com/intellij/execution/runners/AsyncGenericProgramRunner.java @@ -17,16 +17,12 @@ package com.intellij.execution.runners; import com.intellij.execution.ExecutionException; import com.intellij.execution.ExecutionManager; -import com.intellij.execution.Executor; import com.intellij.execution.RunProfileStarter; import com.intellij.execution.configurations.RunProfileState; import com.intellij.execution.configurations.RunnerSettings; import com.intellij.execution.ui.RunContentDescriptor; -import com.intellij.openapi.project.Project; import com.intellij.openapi.util.AsyncResult; import com.intellij.util.Consumer; -import com.intellij.util.NullableConsumer; -import com.intellij.util.ObjectUtils; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -38,30 +34,19 @@ public abstract class AsyncGenericProgramRunner<Settings extends RunnerSettings> @Override protected final void execute(@NotNull final ExecutionEnvironment environment, @Nullable final Callback callback, - @NotNull final Project project, @NotNull final RunProfileState state) throws ExecutionException { - prepare(project, environment, state).doWhenDone(new Consumer<RunProfileStarter>() { + prepare(environment, state).doWhenDone(new Consumer<RunProfileStarter>() { @Override public void consume(@Nullable final RunProfileStarter result) { UIUtil.invokeLaterIfNeeded(new Runnable() { @Override public void run() { - if (!project.isDisposed()) { - startRunProfile(project, environment, state, callback, result); + if (!environment.getProject().isDisposed()) { + startRunProfile(environment, state, callback, result); } } }); } - }).doWhenRejected(new NullableConsumer<String>() { - @Override - public void consume(@Nullable String errorMessage) { - if (project.isDisposed()) { - return; - } - - ExecutionUtil.handleExecutionError(project, environment.getExecutor().getToolWindowId(), environment.getRunProfile(), - new ExecutionException(ObjectUtils.chooseNotNull(errorMessage, "Internal error"))); - } }); } @@ -69,29 +54,23 @@ public abstract class AsyncGenericProgramRunner<Settings extends RunnerSettings> * Makes all the needed preparations for the further execution. Although this method is called in EDT, * these preparations can be performed in a background thread. * - * @param project Project instance + * You must call {@link ExecutionUtil#handleExecutionError} in case of error + * * @param environment ExecutionEnvironment instance * @param state RunProfileState instance * @return RunProfileStarter async result */ @NotNull - protected abstract AsyncResult<RunProfileStarter> prepare(@NotNull Project project, - @NotNull ExecutionEnvironment environment, - @NotNull RunProfileState state) throws ExecutionException; + protected abstract AsyncResult<RunProfileStarter> prepare(@NotNull ExecutionEnvironment environment, @NotNull RunProfileState state) throws ExecutionException; - private static void startRunProfile(@NotNull Project project, - @NotNull ExecutionEnvironment environment, + private static void startRunProfile(@NotNull ExecutionEnvironment environment, @NotNull RunProfileState state, @Nullable final Callback callback, @Nullable final RunProfileStarter starter) { - ExecutionManager.getInstance(project).startRunProfile(new RunProfileStarter() { + ExecutionManager.getInstance(environment.getProject()).startRunProfile(new RunProfileStarter() { @Override - public RunContentDescriptor execute(@NotNull Project project, - @NotNull Executor executor, - @NotNull RunProfileState state, - @Nullable RunContentDescriptor contentToReuse, - @NotNull ExecutionEnvironment environment) throws ExecutionException { - return postProcess(environment, starter == null ? null : starter.execute(project, executor, state, contentToReuse, environment), callback); + public RunContentDescriptor execute(@NotNull RunProfileState state, @NotNull ExecutionEnvironment environment) throws ExecutionException { + return postProcess(environment, starter == null ? null : starter.execute(state, environment), callback); } }, state, environment); } |