mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
cleanup, reduce usage of DefaultProgramRunner
This commit is contained in:
@@ -1,33 +0,0 @@
|
||||
/*
|
||||
* 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.ExecutionException;
|
||||
import com.intellij.execution.configurations.RunProfileState;
|
||||
import com.intellij.execution.ui.RunContentDescriptor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author spleaner
|
||||
*/
|
||||
public abstract class DefaultProgramRunner extends GenericProgramRunner {
|
||||
@Nullable
|
||||
@Override
|
||||
protected RunContentDescriptor doExecute(@NotNull RunProfileState state, @NotNull ExecutionEnvironment env) throws ExecutionException {
|
||||
return DefaultProgramRunnerImplKt.executeState(state, env, this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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.ExecutionException
|
||||
import com.intellij.execution.ExecutionResult
|
||||
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.fileEditor.FileDocumentManager
|
||||
|
||||
abstract class DefaultProgramRunner : GenericProgramRunner<RunnerSettings>() {
|
||||
@Throws(ExecutionException::class)
|
||||
override fun doExecute(state: RunProfileState, env: ExecutionEnvironment): RunContentDescriptor? {
|
||||
return executeState(state, env, this)
|
||||
}
|
||||
}
|
||||
|
||||
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()
|
||||
return showRunContent(state.execute(env.executor, runner), env)
|
||||
}
|
||||
|
||||
fun showRunContent(executionResult: ExecutionResult?, environment: ExecutionEnvironment): RunContentDescriptor? {
|
||||
return executionResult?.let { RunContentBuilder(it, environment).showRunContent(environment.contentToReuse) }
|
||||
}
|
||||
@@ -20,8 +20,6 @@ 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
|
||||
|
||||
@@ -44,14 +42,4 @@ private class DefaultProgramRunnerImpl : AsyncGenericProgramRunner<RunnerSetting
|
||||
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)
|
||||
}
|
||||
@@ -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.
|
||||
@@ -26,11 +26,13 @@ import org.jetbrains.annotations.NotNull;
|
||||
* Time: 19:59:57
|
||||
*/
|
||||
public class XsltRunner extends DefaultProgramRunner {
|
||||
@Override
|
||||
@NotNull
|
||||
public String getRunnerId() {
|
||||
return "XsltProgramRunner";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRun(@NotNull final String executorId, @NotNull final RunProfile profile) {
|
||||
return DefaultRunExecutor.EXECUTOR_ID.equals(executorId) &&
|
||||
profile instanceof XsltRunConfiguration &&
|
||||
|
||||
@@ -4,8 +4,8 @@ import com.intellij.execution.ExecutionException;
|
||||
import com.intellij.execution.ExecutionResult;
|
||||
import com.intellij.execution.configurations.RunProfile;
|
||||
import com.intellij.execution.configurations.RunProfileState;
|
||||
import com.intellij.execution.runners.DefaultProgramRunner;
|
||||
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.xdebugger.XDebugProcess;
|
||||
@@ -15,20 +15,15 @@ import com.intellij.xdebugger.XDebuggerManager;
|
||||
import org.intellij.lang.xpath.xslt.run.XsltCommandLineState;
|
||||
import org.intellij.lang.xpath.xslt.run.XsltRunConfiguration;
|
||||
import org.intellij.plugins.xsltDebugger.impl.XsltDebugProcess;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class XsltDebuggerRunner extends DefaultProgramRunner {
|
||||
public class XsltDebuggerRunner extends GenericProgramRunner {
|
||||
static final ThreadLocal<Boolean> ACTIVE = new ThreadLocal<>();
|
||||
|
||||
@NonNls
|
||||
private static final String ID = "XsltDebuggerRunner";
|
||||
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getRunnerId() {
|
||||
return ID;
|
||||
return "XsltDebuggerRunner";
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -45,6 +40,7 @@ public class XsltDebuggerRunner extends DefaultProgramRunner {
|
||||
protected RunContentDescriptor createContentDescriptor(final RunProfileState runProfileState, final ExecutionEnvironment environment) throws ExecutionException {
|
||||
final XDebugSession debugSession =
|
||||
XDebuggerManager.getInstance(environment.getProject()).startSession(environment, new XDebugProcessStarter() {
|
||||
@Override
|
||||
@NotNull
|
||||
public XDebugProcess start(@NotNull final XDebugSession session) throws ExecutionException {
|
||||
ACTIVE.set(Boolean.TRUE);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2015 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.
|
||||
@@ -20,9 +20,9 @@ import com.intellij.execution.ExecutionResult;
|
||||
import com.intellij.execution.configurations.RunProfile;
|
||||
import com.intellij.execution.configurations.RunProfileState;
|
||||
import com.intellij.execution.executors.DefaultRunExecutor;
|
||||
import com.intellij.execution.runners.DefaultProgramRunner;
|
||||
import com.intellij.execution.runners.DefaultProgramRunnerKt;
|
||||
import com.intellij.execution.runners.ExecutionEnvironment;
|
||||
import com.intellij.execution.runners.RunContentBuilder;
|
||||
import com.intellij.execution.runners.GenericProgramRunner;
|
||||
import com.intellij.execution.ui.RunContentDescriptor;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -30,13 +30,14 @@ import org.jetbrains.annotations.NotNull;
|
||||
/**
|
||||
* @author yole
|
||||
*/
|
||||
public class PythonRunner extends DefaultProgramRunner {
|
||||
|
||||
public class PythonRunner extends GenericProgramRunner {
|
||||
@Override
|
||||
@NotNull
|
||||
public String getRunnerId() {
|
||||
return "PythonRunner";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRun(@NotNull final String executorId, @NotNull final RunProfile profile) {
|
||||
return executorId.equals(DefaultRunExecutor.EXECUTOR_ID) && profile instanceof AbstractPythonRunConfiguration;
|
||||
}
|
||||
@@ -53,6 +54,6 @@ public class PythonRunner extends DefaultProgramRunner {
|
||||
else {
|
||||
executionResult = state.execute(env.getExecutor(), this);
|
||||
}
|
||||
return executionResult == null ? null : new RunContentBuilder(executionResult, env).showRunContent(env.getContentToReuse());
|
||||
return DefaultProgramRunnerKt.showRunContent(executionResult, env);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user