本文整理汇总了Java中com.intellij.execution.configurations.GeneralCommandLine.withWorkDirectory方法的典型用法代码示例。如果您正苦于以下问题:Java GeneralCommandLine.withWorkDirectory方法的具体用法?Java GeneralCommandLine.withWorkDirectory怎么用?Java GeneralCommandLine.withWorkDirectory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.execution.configurations.GeneralCommandLine
的用法示例。
在下文中一共展示了GeneralCommandLine.withWorkDirectory方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doCreateConsoleCmdLine
import com.intellij.execution.configurations.GeneralCommandLine; //导入方法依赖的package包/类
@NotNull
protected GeneralCommandLine doCreateConsoleCmdLine(Sdk sdk,
Map<String, String> environmentVariables,
String workingDir,
int[] ports,
PythonHelper helper) {
PyConsoleOptions.PyConsoleSettings settings = PyConsoleOptions.getInstance(getProject()).getPythonConsoleSettings();
GeneralCommandLine cmd =
PythonCommandLineState.createPythonCommandLine(getProject(), new PythonConsoleRunParams(settings, workingDir, sdk,
environmentVariables));
cmd.withWorkDirectory(getWorkingDir());
ParamsGroup group = cmd.getParametersList().getParamsGroup(PythonCommandLineState.GROUP_SCRIPT);
helper.addToGroup(group, cmd);
for (int port : ports) {
group.addParameter(String.valueOf(port));
}
return cmd;
}
示例2: setWorkingDirectory
import com.intellij.execution.configurations.GeneralCommandLine; //导入方法依赖的package包/类
protected void setWorkingDirectory(@NotNull final GeneralCommandLine cmd) {
final String workingDirectory = myConfiguration.getWorkingDirectory();
if (!StringUtil.isEmptyOrSpaces(workingDirectory)) {
cmd.withWorkDirectory(workingDirectory);
}
else if (myConfiguration instanceof AbstractPythonTestRunConfiguration) {
final String folderName = ((AbstractPythonTestRunConfiguration)myConfiguration).getFolderName();
if (!StringUtil.isEmptyOrSpaces(folderName)) {
cmd.withWorkDirectory(folderName);
}
else {
final String scriptName = ((AbstractPythonTestRunConfiguration)myConfiguration).getScriptName();
if (StringUtil.isEmptyOrSpaces(scriptName)) return;
final VirtualFile script = LocalFileSystem.getInstance().findFileByPath(scriptName);
if (script == null) return;
cmd.withWorkDirectory(script.getParent().getPath());
}
}
if (cmd.getWorkDirectory() == null) { // If current dir still not set, lets use project dir
cmd.setWorkDirectory(myConfiguration.getWorkingDirectorySafe());
}
}
示例3: createCheckProcess
import com.intellij.execution.configurations.GeneralCommandLine; //导入方法依赖的package包/类
Process createCheckProcess(@NotNull final Project project, @NotNull final String executablePath) throws ExecutionException {
final Sdk sdk = PythonSdkType.findPythonSdk(ModuleManager.getInstance(project).getModules()[0]);
PyEduPluginConfigurator configurator = new PyEduPluginConfigurator();
String testsFileName = configurator.getTestFileName();
if (myTask instanceof TaskWithSubtasks) {
testsFileName = FileUtil.getNameWithoutExtension(testsFileName);
int index = ((TaskWithSubtasks)myTask).getActiveSubtaskIndex();
testsFileName += EduNames.SUBTASK_MARKER + index + "." + FileUtilRt.getExtension(configurator.getTestFileName());
}
final File testRunner = new File(myTaskDir.getPath(), testsFileName);
myCommandLine = new GeneralCommandLine();
myCommandLine.withWorkDirectory(myTaskDir.getPath());
final Map<String, String> env = myCommandLine.getEnvironment();
final VirtualFile courseDir = project.getBaseDir();
if (courseDir != null) {
env.put(PYTHONPATH, courseDir.getPath());
}
if (sdk != null) {
String pythonPath = sdk.getHomePath();
if (pythonPath != null) {
myCommandLine.setExePath(pythonPath);
myCommandLine.addParameter(testRunner.getPath());
myCommandLine.addParameter(FileUtil.toSystemDependentName(executablePath));
return myCommandLine.createProcess();
}
}
return null;
}
示例4: createCheckProcess
import com.intellij.execution.configurations.GeneralCommandLine; //导入方法依赖的package包/类
public Process createCheckProcess(@NotNull final Project project, @NotNull final String executablePath) throws ExecutionException {
final Sdk sdk = PythonSdkType.findPythonSdk(ModuleManager.getInstance(project).getModules()[0]);
Course course = myTask.getLesson().getCourse();
StudyLanguageManager manager = StudyUtils.getLanguageManager(course);
if (manager == null) {
LOG.info("Language manager is null for " + course.getLanguageById().getDisplayName());
return null;
}
final File testRunner = new File(myTaskDir.getPath(), manager.getTestFileName());
final GeneralCommandLine commandLine = new GeneralCommandLine();
commandLine.withWorkDirectory(myTaskDir.getPath());
final Map<String, String> env = commandLine.getEnvironment();
final VirtualFile courseDir = project.getBaseDir();
if (courseDir != null) {
env.put(PYTHONPATH, courseDir.getPath());
}
if (sdk != null) {
String pythonPath = sdk.getHomePath();
if (pythonPath != null) {
commandLine.setExePath(pythonPath);
commandLine.addParameter(testRunner.getPath());
File resourceFile = new File(course.getCourseDirectory());
commandLine.addParameter(resourceFile.getPath());
commandLine.addParameter(FileUtil.toSystemDependentName(executablePath));
return commandLine.createProcess();
}
}
return null;
}
示例5: setupJVMCommandLine
import com.intellij.execution.configurations.GeneralCommandLine; //导入方法依赖的package包/类
public static GeneralCommandLine setupJVMCommandLine(final String exePath,
final SimpleJavaParameters javaParameters,
final boolean forceDynamicClasspath) {
final GeneralCommandLine commandLine = new GeneralCommandLine(exePath);
final ParametersList vmParametersList = javaParameters.getVMParametersList();
commandLine.withEnvironment(javaParameters.getEnv());
commandLine.withParentEnvironmentType(javaParameters.isPassParentEnvs() ? ParentEnvironmentType.CONSOLE : ParentEnvironmentType.NONE);
final Class commandLineWrapper;
if ((commandLineWrapper = getCommandLineWrapperClass()) != null) {
if (forceDynamicClasspath && !vmParametersList.hasParameter("-classpath") && !vmParametersList.hasParameter("-cp")) {
if (isClassPathJarEnabled(javaParameters, PathUtil.getJarPathForClass(ClassPath.class))) {
appendJarClasspathParams(javaParameters, commandLine, vmParametersList, commandLineWrapper);
}
else {
appendOldCommandLineWrapper(javaParameters, commandLine, vmParametersList, commandLineWrapper);
}
}
else {
appendParamsEncodingClasspath(javaParameters, commandLine, vmParametersList);
}
}
else {
appendParamsEncodingClasspath(javaParameters, commandLine, vmParametersList);
}
final String mainClass = javaParameters.getMainClass();
final String jarPath = javaParameters.getJarPath();
if (mainClass != null) {
commandLine.addParameter(mainClass);
}
else if (jarPath != null) {
commandLine.addParameter("-jar");
commandLine.addParameter(jarPath);
}
commandLine.addParameters(javaParameters.getProgramParametersList().getList());
commandLine.withWorkDirectory(javaParameters.getWorkingDirectory());
return commandLine;
}