mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
[platform] GeneralCommandLine usages migrated to new parent environment API (IDEA-118946)
This commit is contained in:
@@ -17,6 +17,7 @@ package com.intellij.openapi.projectRoots;
|
||||
|
||||
import com.intellij.execution.CommandLineWrapperUtil;
|
||||
import com.intellij.execution.configurations.GeneralCommandLine;
|
||||
import com.intellij.execution.configurations.GeneralCommandLine.ParentEnvironmentType;
|
||||
import com.intellij.execution.configurations.ParametersList;
|
||||
import com.intellij.execution.configurations.SimpleJavaParameters;
|
||||
import com.intellij.ide.util.PropertiesComponent;
|
||||
@@ -164,12 +165,11 @@ public class JdkUtil {
|
||||
public static GeneralCommandLine setupJVMCommandLine(final String exePath,
|
||||
final SimpleJavaParameters javaParameters,
|
||||
final boolean forceDynamicClasspath) {
|
||||
final GeneralCommandLine commandLine = new GeneralCommandLine();
|
||||
commandLine.setExePath(exePath);
|
||||
final GeneralCommandLine commandLine = new GeneralCommandLine(exePath);
|
||||
|
||||
final ParametersList vmParametersList = javaParameters.getVMParametersList();
|
||||
commandLine.getEnvironment().putAll(javaParameters.getEnv());
|
||||
commandLine.setPassParentEnvironment(javaParameters.isPassParentEnvs());
|
||||
commandLine.withEnvironment(javaParameters.getEnv());
|
||||
commandLine.withParentEnvironmentType(javaParameters.isPassParentEnvs() ? ParentEnvironmentType.SHELL : ParentEnvironmentType.NONE);
|
||||
|
||||
final Class commandLineWrapper;
|
||||
if ((commandLineWrapper = getCommandLineWrapperClass()) != null) {
|
||||
@@ -190,7 +190,7 @@ public class JdkUtil {
|
||||
}
|
||||
|
||||
final String mainClass = javaParameters.getMainClass();
|
||||
String jarPath = javaParameters.getJarPath();
|
||||
final String jarPath = javaParameters.getJarPath();
|
||||
if (mainClass != null) {
|
||||
commandLine.addParameter(mainClass);
|
||||
}
|
||||
|
||||
-2
@@ -151,8 +151,6 @@ public class GeneralCommandLine implements UserDataHolder {
|
||||
return this;
|
||||
}
|
||||
|
||||
/** @deprecated use {@link #getParentEnvironmentType()} (to be removed in IDEA 17) */
|
||||
@SuppressWarnings("unused")
|
||||
public boolean isPassParentEnvironment() {
|
||||
return myParentEnvironmentType != ParentEnvironmentType.NONE;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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.
|
||||
@@ -120,9 +120,7 @@ public final class ScriptRunnerUtil {
|
||||
@Nullable VirtualFile scriptFile,
|
||||
String[] parameters,
|
||||
@Nullable Charset charset) throws ExecutionException {
|
||||
GeneralCommandLine commandLine = new GeneralCommandLine();
|
||||
commandLine.setExePath(exePath);
|
||||
commandLine.setPassParentEnvironment(true);
|
||||
GeneralCommandLine commandLine = new GeneralCommandLine(exePath);
|
||||
if (scriptFile != null) {
|
||||
commandLine.addParameter(scriptFile.getPresentableUrl());
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.intellij.execution;
|
||||
|
||||
import com.intellij.execution.configurations.GeneralCommandLine;
|
||||
import com.intellij.execution.configurations.GeneralCommandLine.ParentEnvironmentType;
|
||||
import com.intellij.execution.process.ProcessOutput;
|
||||
import com.intellij.execution.util.ExecUtil;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
@@ -343,8 +344,8 @@ public class GeneralCommandLineTest {
|
||||
Map<String, String> testEnv,
|
||||
Map<String, String> expectedOutputEnv,
|
||||
boolean passParentEnv) throws ExecutionException, IOException {
|
||||
command.first.getEnvironment().putAll(testEnv);
|
||||
command.first.setPassParentEnvironment(passParentEnv);
|
||||
command.first.withEnvironment(testEnv);
|
||||
command.first.withParentEnvironmentType(passParentEnv ? ParentEnvironmentType.SYSTEM : ParentEnvironmentType.NONE);
|
||||
String output = execHelper(command);
|
||||
|
||||
Set<String> lines = ContainerUtil.newHashSet(StringUtil.convertLineSeparators(output).split("\n"));
|
||||
|
||||
+3
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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.
|
||||
@@ -17,6 +17,7 @@ package com.intellij.cvsSupport2.connections;
|
||||
|
||||
import com.intellij.cvsSupport2.errorHandling.ErrorRegistry;
|
||||
import com.intellij.execution.configurations.GeneralCommandLine;
|
||||
import com.intellij.execution.configurations.GeneralCommandLine.ParentEnvironmentType;
|
||||
import com.intellij.openapi.application.Application;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
@@ -133,7 +134,7 @@ public abstract class ConnectionOnProcess implements IConnection {
|
||||
|
||||
protected synchronized void execute(GeneralCommandLine commandLine) throws AuthenticationException {
|
||||
try {
|
||||
commandLine.setPassParentEnvironment(true);
|
||||
commandLine.withParentEnvironmentType(ParentEnvironmentType.SHELL);
|
||||
myProcess = commandLine.createProcess();
|
||||
|
||||
myErrThread = new ReadProcessThread(
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright 2000-2015 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 org.jetbrains.settingsRepository.git
|
||||
|
||||
import com.intellij.execution.configurations.GeneralCommandLine
|
||||
@@ -16,11 +31,7 @@ fun getCredentialsUsingGit(uri: URIish, repository: Repository): Credentials? {
|
||||
return null
|
||||
}
|
||||
|
||||
val commandLine = GeneralCommandLine()
|
||||
commandLine.setExePath("git")
|
||||
commandLine.addParameter("credential")
|
||||
commandLine.addParameter("fill")
|
||||
commandLine.setPassParentEnvironment(true)
|
||||
val commandLine = GeneralCommandLine("git", "credential", "fill")
|
||||
val process: Process
|
||||
try {
|
||||
process = commandLine.createProcess()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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.
|
||||
@@ -166,7 +166,6 @@ public class SphinxBaseCommand {
|
||||
}
|
||||
}
|
||||
|
||||
cmd.setPassParentEnvironment(true);
|
||||
setPythonIOEncoding(cmd.getEnvironment(), "utf-8");
|
||||
setPythonUnbuffered(cmd.getEnvironment());
|
||||
cmd.getEnvironment().put("PYCHARM_EP_DIST", "Sphinx");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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.
|
||||
@@ -25,7 +25,6 @@ import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.CommonDataKeys;
|
||||
import com.intellij.openapi.actionSystem.LangDataKeys;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -61,10 +60,7 @@ public class CompileQrcAction extends AnAction {
|
||||
return;
|
||||
}
|
||||
|
||||
GeneralCommandLine cmdLine = new GeneralCommandLine();
|
||||
cmdLine.setPassParentEnvironment(true);
|
||||
cmdLine.setExePath(path);
|
||||
cmdLine.addParameters("-o", dialog.getOutputPath());
|
||||
GeneralCommandLine cmdLine = new GeneralCommandLine(path, "-o", dialog.getOutputPath());
|
||||
for (VirtualFile vFile : vFiles) {
|
||||
cmdLine.addParameter(vFile.getPath());
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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.
|
||||
@@ -17,6 +17,7 @@ package com.jetbrains.python.run;
|
||||
|
||||
import com.intellij.execution.*;
|
||||
import com.intellij.execution.configurations.GeneralCommandLine;
|
||||
import com.intellij.execution.configurations.GeneralCommandLine.ParentEnvironmentType;
|
||||
import com.intellij.execution.process.ColoredProcessHandler;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
@@ -118,7 +119,6 @@ public class ProcessRunner {
|
||||
/**
|
||||
* Creates process builder and setups it's commandLine, working directory, environment variables
|
||||
*
|
||||
* @param additionalLoadPath Additional load path
|
||||
* @param workingDir Process working dir
|
||||
* @param executablePath Path to executable file
|
||||
* @param arguments Process commandLine @return process builder
|
||||
@@ -136,20 +136,12 @@ public class ProcessRunner {
|
||||
cmdLine.setWorkDirectory(toSystemDependentName(workingDir));
|
||||
}
|
||||
|
||||
List<String> fixedArguments = new ArrayList<String>();
|
||||
Collections.addAll(fixedArguments, arguments);
|
||||
cmdLine.addParameters(fixedArguments);
|
||||
cmdLine.addParameters(arguments);
|
||||
|
||||
cmdLine.setPassParentEnvironment(passParentEnv);
|
||||
|
||||
//Setting cmdLine params
|
||||
Map<String, String> env = cmdLine.getEnvironment();
|
||||
//User's custom env variables
|
||||
if (userDefinedEnv != null) {
|
||||
env.putAll(userDefinedEnv);
|
||||
}
|
||||
cmdLine.withParentEnvironmentType(passParentEnv ? ParentEnvironmentType.SHELL : ParentEnvironmentType.NONE);
|
||||
cmdLine.withEnvironment(userDefinedEnv);
|
||||
//Inline parent env variables occurrences
|
||||
EnvironmentUtil.inlineParentOccurrences(env);
|
||||
EnvironmentUtil.inlineParentOccurrences(cmdLine.getEnvironment());
|
||||
|
||||
return cmdLine;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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.
|
||||
@@ -22,6 +22,7 @@ import com.intellij.execution.ExecutionException;
|
||||
import com.intellij.execution.ExecutionResult;
|
||||
import com.intellij.execution.Executor;
|
||||
import com.intellij.execution.configurations.*;
|
||||
import com.intellij.execution.configurations.GeneralCommandLine.ParentEnvironmentType;
|
||||
import com.intellij.execution.filters.TextConsoleBuilder;
|
||||
import com.intellij.execution.filters.TextConsoleBuilderFactory;
|
||||
import com.intellij.execution.filters.UrlFilter;
|
||||
@@ -277,7 +278,7 @@ public abstract class PythonCommandLineState extends CommandLineState {
|
||||
|
||||
commandLine.getEnvironment().clear();
|
||||
commandLine.getEnvironment().putAll(env);
|
||||
commandLine.setPassParentEnvironment(myConfig.isPassParentEnvs());
|
||||
commandLine.withParentEnvironmentType(myConfig.isPassParentEnvs() ? ParentEnvironmentType.SHELL : ParentEnvironmentType.NONE);
|
||||
|
||||
buildPythonPath(commandLine, myConfig.isPassParentEnvs());
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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.
|
||||
@@ -152,7 +152,6 @@ public class PythonTask {
|
||||
ParamsGroup scriptParams = cmd.getParametersList().getParamsGroup(PythonCommandLineState.GROUP_SCRIPT);
|
||||
assert scriptParams != null;
|
||||
|
||||
cmd.setPassParentEnvironment(true);
|
||||
Map<String, String> env = cmd.getEnvironment();
|
||||
if (!SystemInfo.isWindows && !PySdkUtil.isRemote(mySdk)) {
|
||||
cmd.setExePath("bash");
|
||||
|
||||
Reference in New Issue
Block a user