move inProgress to ExecutionManagerImpl (part 2 - cleanup)

GitOrigin-RevId: 2548d0a0bb6e5f9e31ada2bb4d095e1f47def5f3
This commit is contained in:
Vladimir Krivosheev
2019-12-18 18:31:49 +00:00
committed by intellij-monorepo-bot
parent f11dba49a9
commit 7ffdc5649b
9 changed files with 37 additions and 41 deletions
@@ -8,6 +8,7 @@ import com.intellij.execution.ui.RunContentManager;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.project.Project;
import com.intellij.util.messages.Topic;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -73,5 +74,10 @@ public abstract class ExecutionManager {
public abstract void restartRunProfile(@NotNull ExecutionEnvironment environment);
public final boolean isStarting(@NotNull ExecutionEnvironment environment) {
return isStarting(environment.getExecutor().getId(), environment.getRunner().getRunnerId());
}
@ApiStatus.Internal
public abstract boolean isStarting(@NotNull String executorId, @NotNull String runnerId);
}
@@ -20,14 +20,15 @@ public abstract class ExecutorRegistry {
public abstract Executor getExecutorById(@NotNull String executorId);
/**
* Consider to use {@link #isStarting(ExecutionEnvironment)}
* Consider to use {@link ExecutionManager#isStarting(ExecutionEnvironment)}
*/
@SuppressWarnings("MethodMayBeStatic")
public final boolean isStarting(@NotNull Project project, @NotNull String executorId, @NotNull String runnerId) {
return ExecutionManager.getInstance(project).isStarting(executorId, runnerId);
}
@SuppressWarnings("MethodMayBeStatic")
public final boolean isStarting(@NotNull ExecutionEnvironment environment) {
return isStarting(environment.getProject(), environment.getExecutor().getId(), environment.getRunner().getRunnerId());
return ExecutionManager.getInstance(environment.getProject()).isStarting(environment);
}
}
@@ -166,8 +166,9 @@ public final class ExecutionUtil {
}
public static void restart(@NotNull ExecutionEnvironment environment) {
if (!ExecutorRegistry.getInstance().isStarting(environment)) {
ExecutionManager.getInstance(environment.getProject()).restartRunProfile(environment);
ExecutionManager executionManager = ExecutionManager.getInstance(environment.getProject());
if (!executionManager.isStarting(environment)) {
executionManager.restartRunProfile(environment);
}
}
@@ -162,7 +162,7 @@ public final class ExecutorRegistryImpl extends ExecutorRegistry implements Disp
myExecutors = null;
}
private class ExecutorAction extends AnAction implements DumbAware, UpdateInBackground {
private static final class ExecutorAction extends AnAction implements DumbAware, UpdateInBackground {
private final Executor myExecutor;
private ExecutorAction(@NotNull final Executor executor) {
@@ -191,7 +191,7 @@ public final class ExecutorRegistryImpl extends ExecutorRegistry implements Disp
ProgramRunner<?> runner = ProgramRunner.getRunner(myExecutor.getId(), configuration);
if (runner == null
|| !ExecutionTargetManager.canRun(configuration, pair.getTarget())
|| isStarting(project, myExecutor.getId(), runner.getRunnerId())) {
|| ExecutionManager.getInstance(project).isStarting(myExecutor.getId(), runner.getRunnerId())) {
return false;
}
}
@@ -285,7 +285,7 @@ public final class ExecutorRegistryImpl extends ExecutorRegistry implements Disp
}
@Nullable
private RunnerAndConfigurationSettings getSelectedConfiguration(@NotNull final Project project) {
private static RunnerAndConfigurationSettings getSelectedConfiguration(@NotNull Project project) {
return RunManager.getInstance(project).getSelectedConfiguration();
}
@@ -49,7 +49,7 @@ public final class ProgramRunnerUtil {
boolean showSettings,
boolean assignNewId,
ProgramRunner.Callback callback) {
if (ExecutorRegistry.getInstance().isStarting(environment)) {
if (ExecutionManager.getInstance(environment.getProject()).isStarting(environment)) {
return;
}
@@ -1,4 +1,4 @@
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.execution.actions;
import com.intellij.execution.*;
@@ -12,6 +12,7 @@ import com.intellij.icons.AllIcons;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.Presentation;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.IconLoader;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.registry.Registry;
@@ -29,7 +30,7 @@ import static com.intellij.execution.SuggestUsingRunDashBoardUtil.promptUserToUs
public class RunContextAction extends BaseRunConfigurationAction {
private final Executor myExecutor;
public RunContextAction(@NotNull final Executor executor) {
public RunContextAction(@NotNull Executor executor) {
super(ExecutionBundle.message("perform.action.with.context.configuration.action.name", executor.getStartActionText()), null, new IconLoader.LazyIcon() {
@NotNull
@Override
@@ -41,7 +42,7 @@ public class RunContextAction extends BaseRunConfigurationAction {
}
@Override
protected void perform(final ConfigurationContext context) {
protected void perform(@NotNull ConfigurationContext context) {
RunnerAndConfigurationSettings configuration = context.findExisting();
final RunManagerEx runManager = (RunManagerEx)context.getRunManager();
if (configuration == null) {
@@ -63,12 +64,12 @@ public class RunContextAction extends BaseRunConfigurationAction {
}
@Override
protected boolean isEnabledFor(RunConfiguration configuration) {
protected boolean isEnabledFor(@NotNull RunConfiguration configuration) {
return getRunner(configuration) != null;
}
@Nullable
private ProgramRunner getRunner(final RunConfiguration configuration) {
private ProgramRunner<?> getRunner(@NotNull RunConfiguration configuration) {
return ProgramRunner.getRunner(myExecutor.getId(), configuration);
}
@@ -94,11 +95,13 @@ public class RunContextAction extends BaseRunConfigurationAction {
configuration = context.getConfiguration();
}
ProgramRunner runner = configuration == null ? null : getRunner(configuration.getConfiguration());
ProgramRunner<?> runner = configuration == null ? null : getRunner(configuration.getConfiguration());
if (runner == null) {
return Pair.create(false, false);
}
return Pair.create(!ExecutorRegistry.getInstance().isStarting(context.getProject(), myExecutor.getId(), runner.getRunnerId()), true);
Project project = context.getProject();
return Pair.create(!ExecutionManager.getInstance(project).isStarting(myExecutor.getId(), runner.getRunnerId()), true);
}
@NotNull
@@ -119,7 +122,7 @@ public class RunContextAction extends BaseRunConfigurationAction {
@NotNull
private AnAction runAllConfigurationsAction(@NotNull ConfigurationContext context, @NotNull List<? extends ConfigurationFromContext> configurationsFromContext) {
return new AnAction(
"Run all",
"Run All",
"Run all configurations available in this context",
AllIcons.RunConfigurations.Compound
) {
@@ -1,4 +1,4 @@
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.execution.dashboard.actions;
import com.intellij.execution.*;
@@ -87,7 +87,7 @@ public abstract class ExecutorAction extends DumbAwareAction {
ProgramRunner<?> runner = ProgramRunner.getRunner(executorId, configuration);
return runner != null && ExecutionTargetManager.canRun(configuration, target) &&
!ExecutorRegistry.getInstance().isStarting(project, executorId, runner.getRunnerId());
!ExecutionManager.getInstance(project).isStarting(executorId, runner.getRunnerId());
}
private static boolean isValid(RunnerAndConfigurationSettings settings) {
@@ -1,23 +1,8 @@
/*
* Copyright 2000-2017 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.execution.runners;
import com.intellij.execution.ExecutionBundle;
import com.intellij.execution.ExecutionManager;
import com.intellij.execution.ExecutorRegistry;
import com.intellij.execution.RunnerAndConfigurationSettings;
import com.intellij.execution.impl.ExecutionManagerImpl;
import com.intellij.execution.process.ProcessHandler;
@@ -90,7 +75,7 @@ public class FakeRerunAction extends AnAction {
if (environment == null || project == null) return false;
RunnerAndConfigurationSettings settings = environment.getRunnerAndConfigurationSettings();
return (!DumbService.isDumb(project) || settings == null || settings.getType().isDumbAware()) &&
!ExecutorRegistry.getInstance().isStarting(environment) &&
!ExecutionManager.getInstance(project).isStarting(environment) &&
!(processHandler != null && processHandler.isProcessTerminating());
}
@@ -61,7 +61,7 @@ final class ProjectStartupRunner implements StartupActivity.DumbAware {
final Executor executor = DefaultRunExecutor.getRunExecutorInstance();
for (final RunnerAndConfigurationSettings configuration : configurations) {
if (! canBeRun(configuration)) {
showNotification(project, "Run Configuration '" + configuration.getName() + "' can not be started with 'Run' action.", MessageType.ERROR);
showNotification(project, "Run Configuration '" + configuration.getName() + "' can not be started with 'Run' action.");
return;
}
@@ -69,15 +69,15 @@ final class ProjectStartupRunner implements StartupActivity.DumbAware {
alarm.addRequest(new MyExecutor(executor, configuration, alarm), pause);
}
catch (ExecutionException e) {
showNotification(project, e.getMessage(), MessageType.ERROR);
showNotification(project, e.getMessage());
}
pause = MyExecutor.PAUSE;
}
}, project.getDisposed());
}
private static void showNotification(Project project, String text, MessageType type) {
ProjectStartupTaskManager.NOTIFICATION_GROUP.createNotification(ProjectStartupTaskManager.PREFIX + " " + text, type).notify(project);
private static void showNotification(Project project, String text) {
ProjectStartupTaskManager.NOTIFICATION_GROUP.createNotification(ProjectStartupTaskManager.PREFIX + " " + text, MessageType.ERROR).notify(project);
}
private static class MyExecutor implements Runnable {
@@ -100,9 +100,9 @@ final class ProjectStartupRunner implements StartupActivity.DumbAware {
@Override
public void run() {
if (ExecutorRegistry.getInstance().isStarting(myEnvironment)) {
if (ExecutionManager.getInstance(myProject).isStarting(myEnvironment)) {
if (myCnt <= 0) {
showNotification(myProject, "'" + myName + "' not started after " + ATTEMPTS + " attempts.", MessageType.ERROR);
showNotification(myProject, "'" + myName + "' not started after " + ATTEMPTS + " attempts.");
return;
}
--myCnt;