From 533cd46101b58fa0241f8bfd940ecfad73a5d50b Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Tue, 8 Nov 2016 14:00:57 +0100 Subject: [PATCH] remove unused/unneeded programm runners, BasicProgramRunner is able to run async --- build/order.txt | 1 - .../execution/runners/BasicProgramRunner.java | 7 +-- .../runners/DebuggableRunProfileState.java | 26 +++++++++ .../runners/DefaultProgramRunner.java | 12 +--- .../runners/DefaultProgramRunnerImpl.kt | 57 +++++++++++++++++++ .../com/intellij/tools/ToolProgramRunner.java | 40 ------------- .../src/META-INF/LangExtensions.xml | 2 - .../src/META-INF/PlatformLangPlugin.xml | 2 +- resources/src/idea/RichPlatformPlugin.xml | 2 +- 9 files changed, 90 insertions(+), 59 deletions(-) create mode 100644 platform/lang-impl/src/com/intellij/execution/runners/DebuggableRunProfileState.java create mode 100644 platform/lang-impl/src/com/intellij/execution/runners/DefaultProgramRunnerImpl.kt delete mode 100644 platform/lang-impl/src/com/intellij/tools/ToolProgramRunner.java diff --git a/build/order.txt b/build/order.txt index 65bd2e4078e4..8e437272bce9 100644 --- a/build/order.txt +++ b/build/order.txt @@ -2527,7 +2527,6 @@ com/intellij/openapi/ui/popup/ListPopupStep.class:/lib/openapi.jar com/intellij/openapi/ui/popup/PopupStep.class:/lib/openapi.jar com/intellij/execution/ExecutionException.class:/lib/openapi.jar com/intellij/execution/runners/Runner.class:/lib/openapi.jar -com/intellij/tools/ToolProgramRunner.class:/lib/idea.jar com/intellij/execution/runners/DefaultProgramRunner.class:/lib/idea.jar com/intellij/execution/runners/GenericProgramRunner.class:/lib/openapi.jar com/intellij/execution/impl/DefaultJavaProgramRunner.class:/lib/idea.jar diff --git a/platform/lang-impl/src/com/intellij/execution/runners/BasicProgramRunner.java b/platform/lang-impl/src/com/intellij/execution/runners/BasicProgramRunner.java index 19c70ba4da2f..418ee293310e 100644 --- a/platform/lang-impl/src/com/intellij/execution/runners/BasicProgramRunner.java +++ b/platform/lang-impl/src/com/intellij/execution/runners/BasicProgramRunner.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2010 JetBrains s.r.o. + * Copyright 2000-2016 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package com.intellij.execution.runners; import com.intellij.execution.configurations.RunProfile; @@ -21,10 +20,10 @@ import com.intellij.execution.executors.DefaultRunExecutor; import org.jetbrains.annotations.NotNull; /** - * @author AG + * @deprecated Do not use and do not extends — use DefaultProgramRunner instead. */ +@Deprecated public class BasicProgramRunner extends DefaultProgramRunner { - @NotNull @Override public String getRunnerId() { diff --git a/platform/lang-impl/src/com/intellij/execution/runners/DebuggableRunProfileState.java b/platform/lang-impl/src/com/intellij/execution/runners/DebuggableRunProfileState.java new file mode 100644 index 000000000000..692e788da3ca --- /dev/null +++ b/platform/lang-impl/src/com/intellij/execution/runners/DebuggableRunProfileState.java @@ -0,0 +1,26 @@ +/* + * Copyright 2000-2016 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. + */ +package com.intellij.execution.runners; + +import com.intellij.execution.ExecutionResult; +import com.intellij.execution.configurations.RunProfileState; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.concurrency.Promise; + +public interface DebuggableRunProfileState extends RunProfileState { + @NotNull + Promise execute(int debugPort); +} diff --git a/platform/lang-impl/src/com/intellij/execution/runners/DefaultProgramRunner.java b/platform/lang-impl/src/com/intellij/execution/runners/DefaultProgramRunner.java index 2c05390a0d10..fe793ce1a3cc 100644 --- a/platform/lang-impl/src/com/intellij/execution/runners/DefaultProgramRunner.java +++ b/platform/lang-impl/src/com/intellij/execution/runners/DefaultProgramRunner.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2016 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. @@ -13,14 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package com.intellij.execution.runners; import com.intellij.execution.ExecutionException; -import com.intellij.execution.ExecutionResult; import com.intellij.execution.configurations.RunProfileState; import com.intellij.execution.ui.RunContentDescriptor; -import com.intellij.openapi.fileEditor.FileDocumentManager; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -31,11 +28,6 @@ public abstract class DefaultProgramRunner extends GenericProgramRunner { @Nullable @Override 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(env.getContentToReuse()); + return DefaultProgramRunnerImplKt.executeState(state, env, this); } } diff --git a/platform/lang-impl/src/com/intellij/execution/runners/DefaultProgramRunnerImpl.kt b/platform/lang-impl/src/com/intellij/execution/runners/DefaultProgramRunnerImpl.kt new file mode 100644 index 000000000000..87e1cc0742c9 --- /dev/null +++ b/platform/lang-impl/src/com/intellij/execution/runners/DefaultProgramRunnerImpl.kt @@ -0,0 +1,57 @@ +/* + * Copyright 2000-2016 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. + */ +package com.intellij.execution.runners + +import com.intellij.execution.RunProfileStarter +import com.intellij.execution.configurations.RunProfile +import com.intellij.execution.configurations.RunProfileState +import com.intellij.execution.configurations.RunnerSettings +import com.intellij.execution.executors.DefaultRunExecutor +import com.intellij.execution.ui.RunContentDescriptor +import com.intellij.openapi.fileEditor.FileDocumentManager +import org.jetbrains.concurrency.Promise +import org.jetbrains.concurrency.resolvedPromise + +private class DefaultProgramRunnerImpl : AsyncGenericProgramRunner() { + override fun getRunnerId() = "defaultRunner" + + override fun prepare(environment: ExecutionEnvironment, state: RunProfileState): Promise { + if (state is DebuggableRunProfileState) { + return state.execute(-1) + .then { + it?.let { + runProfileStarter { state, environment -> RunContentBuilder(it, environment).showRunContent(environment.contentToReuse) } + } + } + } + + return resolvedPromise(runProfileStarter { state, environment -> executeState(state, environment, this) }) + } + + override fun canRun(executorId: String, profile: RunProfile): Boolean { + return DefaultRunExecutor.EXECUTOR_ID == executorId && profile !is RunConfigurationWithSuppressedDefaultRunAction + } +} + +inline fun runProfileStarter(crossinline starter: (state: RunProfileState, environment: ExecutionEnvironment) -> RunContentDescriptor?) = object : RunProfileStarter() { + override fun execute(state: RunProfileState, env: ExecutionEnvironment) = starter(state, env) +} + +internal fun executeState(state: RunProfileState, env: ExecutionEnvironment, runner: ProgramRunner<*>): RunContentDescriptor? { + FileDocumentManager.getInstance().saveAllDocuments() + val executionResult = state.execute(env.executor, runner) ?: return null + return RunContentBuilder(executionResult, env).showRunContent(env.contentToReuse) +} \ No newline at end of file diff --git a/platform/lang-impl/src/com/intellij/tools/ToolProgramRunner.java b/platform/lang-impl/src/com/intellij/tools/ToolProgramRunner.java deleted file mode 100644 index 2c41ff7edcae..000000000000 --- a/platform/lang-impl/src/com/intellij/tools/ToolProgramRunner.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2000-2009 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. - */ - -package com.intellij.tools; - -import com.intellij.execution.configurations.RunProfile; -import com.intellij.execution.executors.DefaultRunExecutor; -import com.intellij.execution.runners.DefaultProgramRunner; -import org.jetbrains.annotations.NotNull; - -/** - * @author spleaner - */ -public class ToolProgramRunner extends DefaultProgramRunner { - - @Override - @NotNull - public String getRunnerId() { - return "ToolProgramRunner"; - } - - @Override - public boolean canRun(@NotNull final String executorId, @NotNull final RunProfile profile) { - return DefaultRunExecutor.EXECUTOR_ID.equals(executorId) && profile instanceof ToolRunProfile; - } - -} diff --git a/platform/platform-resources/src/META-INF/LangExtensions.xml b/platform/platform-resources/src/META-INF/LangExtensions.xml index 68c4e5ecadc8..8948df13a53f 100644 --- a/platform/platform-resources/src/META-INF/LangExtensions.xml +++ b/platform/platform-resources/src/META-INF/LangExtensions.xml @@ -523,8 +523,6 @@ - - diff --git a/platform/platform-resources/src/META-INF/PlatformLangPlugin.xml b/platform/platform-resources/src/META-INF/PlatformLangPlugin.xml index 9e7583286cf2..4c7beb1e2b46 100644 --- a/platform/platform-resources/src/META-INF/PlatformLangPlugin.xml +++ b/platform/platform-resources/src/META-INF/PlatformLangPlugin.xml @@ -75,7 +75,7 @@ - + diff --git a/resources/src/idea/RichPlatformPlugin.xml b/resources/src/idea/RichPlatformPlugin.xml index 79f8d9d9e66a..8a7eab221bcf 100644 --- a/resources/src/idea/RichPlatformPlugin.xml +++ b/resources/src/idea/RichPlatformPlugin.xml @@ -341,7 +341,7 @@ - +