mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
Use helpers enum constants where possible.
This commit is contained in:
@@ -26,6 +26,7 @@ import com.intellij.execution.runners.ExecutionEnvironment;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.jetbrains.python.PythonHelper;
|
||||
import com.jetbrains.python.PythonHelpersLocator;
|
||||
import com.jetbrains.python.run.PythonCommandLineState;
|
||||
import com.jetbrains.python.run.PythonProcessRunner;
|
||||
@@ -48,28 +49,26 @@ public abstract class RestCommandLineState extends PythonCommandLineState {
|
||||
@Override
|
||||
protected void buildCommandLineParameters(GeneralCommandLine commandLine) {
|
||||
ParametersList parametersList = commandLine.getParametersList();
|
||||
ParamsGroup exe_options = parametersList.getParamsGroup(GROUP_EXE_OPTIONS);
|
||||
assert exe_options != null;
|
||||
exe_options.addParametersString(myConfiguration.getInterpreterOptions());
|
||||
ParamsGroup exeOptions = parametersList.getParamsGroup(GROUP_EXE_OPTIONS);
|
||||
assert exeOptions != null;
|
||||
exeOptions.addParametersString(myConfiguration.getInterpreterOptions());
|
||||
|
||||
ParamsGroup script_parameters = parametersList.getParamsGroup(GROUP_SCRIPT);
|
||||
assert script_parameters != null;
|
||||
String runner = PythonHelpersLocator.getHelperPath(getRunnerPath());
|
||||
if (runner != null )
|
||||
script_parameters.addParameter(runner);
|
||||
ParamsGroup scriptParameters = parametersList.getParamsGroup(GROUP_SCRIPT);
|
||||
assert scriptParameters != null;
|
||||
getRunner().addToGroup(scriptParameters, commandLine);
|
||||
final String key = getKey();
|
||||
if (key != null)
|
||||
script_parameters.addParameter(key);
|
||||
script_parameters.addParameter(getTask());
|
||||
scriptParameters.addParameter(key);
|
||||
scriptParameters.addParameter(getTask());
|
||||
|
||||
final String params = myConfiguration.getParams();
|
||||
if (params != null) script_parameters.addParametersString(params);
|
||||
if (params != null) scriptParameters.addParametersString(params);
|
||||
|
||||
if (!StringUtil.isEmptyOrSpaces(myConfiguration.getInputFile()))
|
||||
script_parameters.addParameter(myConfiguration.getInputFile());
|
||||
scriptParameters.addParameter(myConfiguration.getInputFile());
|
||||
|
||||
if (!StringUtil.isEmptyOrSpaces(myConfiguration.getOutputFile()))
|
||||
script_parameters.addParameter(myConfiguration.getOutputFile());
|
||||
scriptParameters.addParameter(myConfiguration.getOutputFile());
|
||||
|
||||
if (!StringUtil.isEmptyOrSpaces(myConfiguration.getWorkingDirectory()))
|
||||
commandLine.setWorkDirectory(myConfiguration.getWorkingDirectory());
|
||||
@@ -106,7 +105,7 @@ public abstract class RestCommandLineState extends PythonCommandLineState {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected abstract String getRunnerPath();
|
||||
protected abstract PythonHelper getRunner();
|
||||
|
||||
protected abstract String getTask();
|
||||
|
||||
|
||||
+4
-2
@@ -19,6 +19,8 @@ import com.intellij.execution.runners.ExecutionEnvironment;
|
||||
import com.intellij.ide.BrowserUtil;
|
||||
import com.intellij.openapi.fileEditor.FileEditorManager;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.jetbrains.python.PythonHelper;
|
||||
import com.jetbrains.python.PythonHelpersLocator;
|
||||
import com.jetbrains.rest.run.RestCommandLineState;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -51,8 +53,8 @@ public class DocutilsCommandLineState extends RestCommandLineState {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getRunnerPath() {
|
||||
return "rest_runners/rst2smth.py";
|
||||
protected PythonHelper getRunner() {
|
||||
return PythonHelpersLocator.REST_RUNNER;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,6 +18,8 @@ package com.jetbrains.rest.run.sphinx;
|
||||
import com.intellij.execution.runners.ExecutionEnvironment;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.jetbrains.python.PythonHelper;
|
||||
import com.jetbrains.python.PythonHelpersLocator;
|
||||
import com.jetbrains.rest.run.RestCommandLineState;
|
||||
|
||||
import java.util.Collections;
|
||||
@@ -45,8 +47,8 @@ public class SphinxCommandLineState extends RestCommandLineState {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getRunnerPath() {
|
||||
return "rest_runners/sphinx_runner.py";
|
||||
protected PythonHelper getRunner() {
|
||||
return PythonHelpersLocator.SPHINX_RUNNER;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -139,30 +139,25 @@ public class SphinxBaseCommand {
|
||||
}
|
||||
|
||||
protected GeneralCommandLine createCommandLine(Module module, List<String> params) throws ExecutionException {
|
||||
GeneralCommandLine cmd = new GeneralCommandLine();
|
||||
|
||||
Sdk sdk = PythonSdkType.findPythonSdk(module);
|
||||
if (sdk == null) {
|
||||
throw new ExecutionException("No sdk specified");
|
||||
}
|
||||
|
||||
ReSTService service = ReSTService.getInstance(module);
|
||||
|
||||
String sdkHomePath = sdk.getHomePath();
|
||||
|
||||
final GeneralCommandLine cmd = PythonHelpersLocator.LOAD_ENTRY_POINT.newCommandLine(sdkHomePath, Lists.<String>newArrayList());
|
||||
|
||||
cmd.setWorkDirectory(service.getWorkdir().isEmpty()? module.getProject().getBaseDir().getPath(): service.getWorkdir());
|
||||
PythonCommandLineState.createStandardGroups(cmd);
|
||||
ParamsGroup script_params = cmd.getParametersList().getParamsGroup(PythonCommandLineState.GROUP_SCRIPT);
|
||||
assert script_params != null;
|
||||
ParamsGroup scriptParams = cmd.getParametersList().getParamsGroup(PythonCommandLineState.GROUP_SCRIPT);
|
||||
assert scriptParams != null;
|
||||
|
||||
String commandPath = PythonHelpersLocator.getHelperPath("pycharm/pycharm_load_entry_point.py");
|
||||
if (commandPath == null) {
|
||||
throw new ExecutionException("Cannot find sphinx-quickstart.");
|
||||
}
|
||||
final String sdkHomePath = sdk.getHomePath();
|
||||
if (sdkHomePath != null)
|
||||
cmd.setExePath(sdkHomePath);
|
||||
cmd.addParameter(commandPath);
|
||||
if (params != null) {
|
||||
for (String p : params) {
|
||||
script_params.addParameter(p);
|
||||
scriptParams.addParameter(p);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user