diff options
Diffstat (limited to 'platform/lang-impl/src/com/intellij/execution/runners/RerunTestsAction.java')
-rw-r--r-- | platform/lang-impl/src/com/intellij/execution/runners/RerunTestsAction.java | 71 |
1 files changed, 13 insertions, 58 deletions
diff --git a/platform/lang-impl/src/com/intellij/execution/runners/RerunTestsAction.java b/platform/lang-impl/src/com/intellij/execution/runners/RerunTestsAction.java index c4e8fd0a3e0d..8d3bf8663598 100644 --- a/platform/lang-impl/src/com/intellij/execution/runners/RerunTestsAction.java +++ b/platform/lang-impl/src/com/intellij/execution/runners/RerunTestsAction.java @@ -1,13 +1,11 @@ package com.intellij.execution.runners; -import com.intellij.execution.ExecutionManager; -import com.intellij.execution.ExecutorRegistry; import com.intellij.execution.process.ProcessHandler; import com.intellij.execution.ui.RunContentDescriptor; import com.intellij.openapi.Disposable; -import com.intellij.openapi.actionSystem.*; +import com.intellij.openapi.actionSystem.AnAction; +import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.project.DumbAwareAction; -import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Disposer; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; @@ -25,41 +23,27 @@ import java.util.List; * @author Sergey Simonchik */ public class RerunTestsAction extends DumbAwareAction implements AnAction.TransparentUpdate { - public static final String ID = "RerunTests"; - private static final List<RerunInfo> REGISTRY = ContainerUtil.createLockFreeCopyOnWriteList(); + private static final List<ExecutionEnvironment> REGISTRY = ContainerUtil.createLockFreeCopyOnWriteList(); - public static void register(@NotNull RunContentDescriptor descriptor, - @NotNull ExecutionEnvironment env, - @NotNull ProgramRunner runner) { - final RerunInfo rerunInfo = new RerunInfo(descriptor, env, runner); - REGISTRY.add(rerunInfo); - Disposer.register(descriptor, new Disposable() { + public static void register(@NotNull final ExecutionEnvironment environment) { + REGISTRY.add(environment); + Disposer.register(environment, new Disposable() { @Override public void dispose() { - REGISTRY.remove(rerunInfo); + REGISTRY.remove(environment); } }); } @Override public void actionPerformed(AnActionEvent e) { - DataContext dataContext = e.getDataContext(); - Project project = CommonDataKeys.PROJECT.getData(dataContext); - if (project == null) { - return; - } - ExecutionManager executionManager = ExecutionManager.getInstance(project); - for (RerunInfo rerunInfo : REGISTRY) { - RunContentDescriptor descriptor = rerunInfo.getDescriptor(); - if (!Disposer.isDisposed(descriptor)) { - ExecutionEnvironment env = rerunInfo.getEnv(); - ProgramRunner runner = rerunInfo.getRunner(); - ProcessHandler processHandler = descriptor.getProcessHandler(); + for (ExecutionEnvironment environment : REGISTRY) { + if (!Disposer.isDisposed(environment)) { + RunContentDescriptor descriptor = environment.getContentToReuse(); + ProcessHandler processHandler = descriptor == null ? null : descriptor.getProcessHandler(); if (processHandler != null && processHandler.isProcessTerminated()) { - if (!ExecutorRegistry.getInstance().isStarting(project, env.getExecutor().getId(), runner.getRunnerId())) { - executionManager.restartRunProfile(runner, env, descriptor); - } + ExecutionUtil.restart(environment); } } } @@ -67,35 +51,6 @@ public class RerunTestsAction extends DumbAwareAction implements AnAction.Transp @Override public void update(AnActionEvent e) { - Presentation presentation = e.getPresentation(); - presentation.setEnabled(true); - } - - private static class RerunInfo { - - private final RunContentDescriptor myDescriptor; - private final ExecutionEnvironment myEnv; - private final ProgramRunner myRunner; - - public RerunInfo(@NotNull RunContentDescriptor descriptor, - @NotNull ExecutionEnvironment env, - @NotNull ProgramRunner runner) { - myDescriptor = descriptor; - myEnv = env; - myRunner = runner; - } - - private RunContentDescriptor getDescriptor() { - return myDescriptor; - } - - private ExecutionEnvironment getEnv() { - return myEnv; - } - - private ProgramRunner getRunner() { - return myRunner; - } + e.getPresentation().setEnabled(true); } - } |