mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Respect python console path mapping settings (PY-14198)
This commit is contained in:
@@ -145,6 +145,7 @@ public class PydevConsoleRunner extends AbstractConsoleRunnerWithHistory<PythonC
|
||||
private final PyConsoleType myConsoleType;
|
||||
private Map<String, String> myEnvironmentVariables;
|
||||
private String myCommandLine;
|
||||
@NotNull private final PyConsoleOptions.PyConsoleSettings myConsoleSettings;
|
||||
private String[] myStatementsToExecute = ArrayUtil.EMPTY_STRING_ARRAY;
|
||||
|
||||
public static Key<ConsoleCommunication> CONSOLE_KEY = new Key<ConsoleCommunication>("PYDEV_CONSOLE_KEY");
|
||||
@@ -158,18 +159,23 @@ public class PydevConsoleRunner extends AbstractConsoleRunnerWithHistory<PythonC
|
||||
private String myConsoleTitle = null;
|
||||
|
||||
public PydevConsoleRunner(@NotNull final Project project,
|
||||
@NotNull Sdk sdk, @NotNull final PyConsoleType consoleType,
|
||||
@NotNull Sdk sdk,
|
||||
@NotNull final PyConsoleType consoleType,
|
||||
@Nullable final String workingDir,
|
||||
Map<String, String> environmentVariables, String... statementsToExecute) {
|
||||
Map<String, String> environmentVariables,
|
||||
@NotNull
|
||||
PyConsoleOptions.PyConsoleSettings settingsProvider,
|
||||
String... statementsToExecute) {
|
||||
super(project, consoleType.getTitle(), workingDir);
|
||||
mySdk = sdk;
|
||||
myConsoleType = consoleType;
|
||||
myEnvironmentVariables = environmentVariables;
|
||||
myConsoleSettings = settingsProvider;
|
||||
myStatementsToExecute = statementsToExecute;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static PyRemotePathMapper getPathMapper(@NotNull Project project, Sdk sdk) {
|
||||
public static PyRemotePathMapper getPathMapper(@NotNull Project project, Sdk sdk, PyConsoleOptions.PyConsoleSettings consoleSettings) {
|
||||
if (PySdkUtil.isRemote(sdk)) {
|
||||
PythonRemoteInterpreterManager instance = PythonRemoteInterpreterManager.getInstance();
|
||||
if (instance != null) {
|
||||
@@ -177,7 +183,7 @@ public class PydevConsoleRunner extends AbstractConsoleRunnerWithHistory<PythonC
|
||||
PyRemotePathMapper remotePathMapper =
|
||||
instance.setupMappings(project, (PyRemoteSdkAdditionalDataBase)sdk.getSdkAdditionalData(), null);
|
||||
|
||||
PathMappingSettings mappingSettings = PyConsoleOptions.getInstance(project).getPythonConsoleSettings().getMappingSettings();
|
||||
PathMappingSettings mappingSettings = consoleSettings.getMappingSettings();
|
||||
|
||||
remotePathMapper.addAll(mappingSettings.getPathMappings(), PyRemotePathMapper.PyPathMappingType.USER_DEFINED);
|
||||
|
||||
@@ -461,11 +467,8 @@ public class PydevConsoleRunner extends AbstractConsoleRunnerWithHistory<PythonC
|
||||
String workingDir,
|
||||
int[] ports,
|
||||
PythonHelper helper) {
|
||||
PyConsoleOptions.PyConsoleSettings settings = PyConsoleOptions.getInstance(getProject()).getPythonConsoleSettings();
|
||||
|
||||
|
||||
GeneralCommandLine cmd =
|
||||
PythonCommandLineState.createPythonCommandLine(getProject(), new PythonConsoleRunParams(settings, workingDir, sdk,
|
||||
PythonCommandLineState.createPythonCommandLine(getProject(), new PythonConsoleRunParams(myConsoleSettings, workingDir, sdk,
|
||||
environmentVariables), false,
|
||||
PtyCommandLine.isEnabled() && !SystemInfo.isWindows);
|
||||
cmd.withWorkDirectory(getWorkingDir());
|
||||
@@ -543,7 +546,7 @@ public class PydevConsoleRunner extends AbstractConsoleRunnerWithHistory<PythonC
|
||||
commandLine.getParametersList().set(2, "0");
|
||||
|
||||
try {
|
||||
PyRemotePathMapper pathMapper = getPathMapper(getProject(), mySdk);
|
||||
PyRemotePathMapper pathMapper = getPathMapper(getProject(), mySdk, myConsoleSettings);
|
||||
|
||||
assert pathMapper != null;
|
||||
|
||||
|
||||
@@ -36,8 +36,8 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author traff
|
||||
*/
|
||||
* @author traff
|
||||
*/
|
||||
public class PydevConsoleRunnerFactory extends PythonConsoleRunnerFactory {
|
||||
@Override
|
||||
public PydevConsoleRunner createConsoleRunner(@NotNull Project project,
|
||||
@@ -49,11 +49,12 @@ public class PydevConsoleRunnerFactory extends PythonConsoleRunnerFactory {
|
||||
|
||||
assert sdk != null;
|
||||
|
||||
PathMapper pathMapper = PydevConsoleRunner.getPathMapper(project, sdk);
|
||||
PyConsoleOptions.PyConsoleSettings settingsProvider = PyConsoleOptions.getInstance(project).getPythonConsoleSettings();
|
||||
|
||||
PathMapper pathMapper = PydevConsoleRunner.getPathMapper(project, sdk, settingsProvider);
|
||||
|
||||
String[] setupFragment;
|
||||
|
||||
PyConsoleOptions.PyConsoleSettings settingsProvider = PyConsoleOptions.getInstance(project).getPythonConsoleSettings();
|
||||
Collection<String> pythonPath = PythonCommandLineState.collectPythonPath(module, settingsProvider.shouldAddContentRoots(),
|
||||
settingsProvider.shouldAddSourceRoots());
|
||||
|
||||
@@ -108,15 +109,17 @@ public class PydevConsoleRunnerFactory extends PythonConsoleRunnerFactory {
|
||||
Map<String, String> envs = Maps.newHashMap(settingsProvider.getEnvs());
|
||||
String ipythonEnabled = PyConsoleOptions.getInstance(project).isIpythonEnabled() ? "True" : "False";
|
||||
envs.put(PythonEnvUtil.IPYTHONENABLE, ipythonEnabled);
|
||||
|
||||
|
||||
return createConsoleRunner(project, sdk, workingDir, envs, PyConsoleType.PYTHON, setupFragment);
|
||||
|
||||
return createConsoleRunner(project, sdk, workingDir, envs, PyConsoleType.PYTHON, settingsProvider, setupFragment);
|
||||
}
|
||||
|
||||
protected PydevConsoleRunner createConsoleRunner(Project project,
|
||||
Sdk sdk,
|
||||
String workingDir,
|
||||
Map<String, String> envs, PyConsoleType consoleType, String ... setupFragment) {
|
||||
return new PydevConsoleRunner(project, sdk, consoleType, workingDir, envs, setupFragment);
|
||||
Map<String, String> envs,
|
||||
PyConsoleType consoleType,
|
||||
PyConsoleOptions.PyConsoleSettings settingsProvider,
|
||||
String... setupFragment) {
|
||||
return new PydevConsoleRunner(project, sdk, consoleType, workingDir, envs, settingsProvider, setupFragment);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,11 +39,12 @@ public class PythonToolWindowConsoleRunner extends PydevConsoleRunner {
|
||||
private ToolWindow myToolWindow;
|
||||
|
||||
public PythonToolWindowConsoleRunner(@NotNull Project project,
|
||||
@NotNull Sdk sdk,
|
||||
@NotNull PyConsoleType consoleType,
|
||||
@Nullable String workingDir, Map<String, String> environmentVariables,
|
||||
String ... statementsToExecute) {
|
||||
super(project, sdk, consoleType, workingDir, environmentVariables, statementsToExecute);
|
||||
@NotNull Sdk sdk,
|
||||
@NotNull PyConsoleType consoleType,
|
||||
@Nullable String workingDir, Map<String, String> environmentVariables,
|
||||
@NotNull PyConsoleOptions.PyConsoleSettings settingsProvider,
|
||||
String... statementsToExecute) {
|
||||
super(project, sdk, consoleType, workingDir, environmentVariables, settingsProvider, statementsToExecute);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,6 +17,7 @@ package com.jetbrains.python.console;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -28,7 +29,8 @@ public class PythonToolWindowConsoleRunnerFactory extends PydevConsoleRunnerFact
|
||||
protected PydevConsoleRunner createConsoleRunner(Project project,
|
||||
Sdk sdk,
|
||||
String workingDir,
|
||||
Map<String, String> envs, PyConsoleType consoleType, String ... setupFragment) {
|
||||
return new PythonToolWindowConsoleRunner(project, sdk, consoleType, workingDir, envs, setupFragment);
|
||||
Map<String, String> envs, PyConsoleType consoleType,
|
||||
@NotNull PyConsoleOptions.PyConsoleSettings settingsProvider, String... setupFragment) {
|
||||
return new PythonToolWindowConsoleRunner(project, sdk, consoleType, workingDir, envs, settingsProvider, setupFragment);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.jetbrains.python.PythonHelper;
|
||||
import com.jetbrains.python.console.PyConsoleOptions;
|
||||
import com.jetbrains.python.console.PyConsoleType;
|
||||
import com.jetbrains.python.console.PydevConsoleRunner;
|
||||
import com.jetbrains.python.sdk.PythonEnvUtil;
|
||||
@@ -66,7 +67,8 @@ public class PythonScriptCommandLineState extends PythonCommandLineState {
|
||||
|
||||
PydevConsoleRunner runner =
|
||||
new PythonScriptWithConsoleRunner(myConfig.getProject(), myConfig.getSdk(), PyConsoleType.PYTHON, myConfig.getWorkingDirectory(),
|
||||
myConfig.getEnvs(), patchers);
|
||||
myConfig.getEnvs(), patchers,
|
||||
PyConsoleOptions.getInstance(myConfig.getProject()).getPythonConsoleSettings());
|
||||
|
||||
runner.runSync();
|
||||
|
||||
@@ -113,8 +115,9 @@ public class PythonScriptCommandLineState extends PythonCommandLineState {
|
||||
@Nullable String workingDir,
|
||||
Map<String, String> environmentVariables,
|
||||
CommandLinePatcher[] patchers,
|
||||
PyConsoleOptions.PyConsoleSettings consoleSettings,
|
||||
String... statementsToExecute) {
|
||||
super(project, sdk, consoleType, workingDir, environmentVariables, statementsToExecute);
|
||||
super(project, sdk, consoleType, workingDir, environmentVariables, consoleSettings, statementsToExecute);
|
||||
myPatchers = patchers;
|
||||
}
|
||||
|
||||
|
||||
@@ -151,7 +151,8 @@ public class PyConsoleTask extends PyExecutionFixtureTestTask {
|
||||
setProcessCanTerminate(false);
|
||||
|
||||
PydevConsoleRunner consoleRunner =
|
||||
new PydevConsoleRunner(project, sdk, PyConsoleType.PYTHON, getWorkingFolder(), Maps.<String, String>newHashMap(), new String[]{}) {
|
||||
new PydevConsoleRunner(project, sdk, PyConsoleType.PYTHON, getWorkingFolder(), Maps.<String, String>newHashMap(), PyConsoleOptions.getInstance(project).getPythonConsoleSettings(),
|
||||
new String[]{}) {
|
||||
@Override
|
||||
protected void showConsole(Executor defaultExecutor, @NotNull RunContentDescriptor contentDescriptor) {
|
||||
myContentDescriptorRef.set(contentDescriptor);
|
||||
|
||||
Reference in New Issue
Block a user