mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Add possibility for flavor to patch command line before execution (https://github.com/JetBrains/intellij-community/pull/534)
This commit is contained in:
@@ -33,6 +33,8 @@ import com.intellij.psi.PsiFile;
|
||||
import com.intellij.remote.RemoteSdkAdditionalData;
|
||||
import com.intellij.util.SystemProperties;
|
||||
import com.intellij.util.containers.HashMap;
|
||||
import com.jetbrains.python.run.CommandLinePatcher;
|
||||
import com.jetbrains.python.sdk.flavors.PythonSdkFlavor;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -125,6 +127,14 @@ public class PySdkUtil {
|
||||
try {
|
||||
|
||||
final GeneralCommandLine commandLine = cmd.withWorkDirectory(homePath).withEnvironment(env);
|
||||
|
||||
final PythonSdkFlavor flavor = PythonSdkFlavor.getFlavor(commandLine.getExePath());
|
||||
|
||||
final CommandLinePatcher cmdLinePatcher = flavor.commandLinePatcher();
|
||||
if (cmdLinePatcher != null) {
|
||||
cmdLinePatcher.patchCommandLine(cmd);
|
||||
}
|
||||
|
||||
final CapturingProcessHandler processHandler = new CapturingProcessHandler(commandLine);
|
||||
if (stdin != null) {
|
||||
final OutputStream processInput = processHandler.getProcessInput();
|
||||
|
||||
@@ -66,6 +66,7 @@ public class PythonEnvUtil {
|
||||
* @param value what to append
|
||||
* @return modified path-like string
|
||||
*/
|
||||
|
||||
@NotNull
|
||||
public static String appendToPathEnvVar(@Nullable String source, @NotNull String value) {
|
||||
if (StringUtil.isEmpty(source)) return value;
|
||||
|
||||
@@ -29,6 +29,7 @@ import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.PatternUtil;
|
||||
import com.jetbrains.python.psi.LanguageLevel;
|
||||
import com.jetbrains.python.run.CommandLinePatcher;
|
||||
import com.jetbrains.python.sdk.PySdkUtil;
|
||||
import com.jetbrains.python.sdk.PythonEnvUtil;
|
||||
import com.jetbrains.python.sdk.PythonSdkAdditionalData;
|
||||
@@ -256,4 +257,9 @@ public abstract class PythonSdkFlavor {
|
||||
public VirtualFile getSdkPath(VirtualFile path) {
|
||||
return path;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public CommandLinePatcher commandLinePatcher() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user