use of com.intellij.execution.process.OSProcessHandler in project buck by facebook.
the class TestExecutionState method runBuildCommand.
private ProcessHandler runBuildCommand(Executor executor) {
final BuckModule buckModule = mProject.getComponent(BuckModule.class);
final String target = mConfiguration.data.target;
final String additionalParams = mConfiguration.data.additionalParams;
final String testSelectors = mConfiguration.data.testSelectors;
final String title = "Buck Test " + target;
buckModule.attach(target);
final BuckBuildCommandHandler handler = new BuckBuildCommandHandler(mProject, mProject.getBaseDir(), BuckCommand.TEST, /* doStartNotify */
false) {
@Override
protected void notifyLines(Key outputType, Iterable<String> lines) {
super.notifyLines(outputType, lines);
if (outputType != ProcessOutputTypes.STDERR) {
return;
}
for (String line : lines) {
final Matcher matcher = DEBUG_SUSPEND_PATTERN.matcher(line);
if (matcher.find()) {
final String port = matcher.group(1);
attachDebugger(title, port);
}
}
}
};
if (!target.isEmpty()) {
handler.command().addParameter(target);
}
if (!testSelectors.isEmpty()) {
handler.command().addParameter("--test-selectors");
handler.command().addParameter(testSelectors);
}
if (!additionalParams.isEmpty()) {
for (String param : additionalParams.split("\\s")) {
handler.command().addParameter(param);
}
}
if (executor.getId().equals(DefaultDebugExecutor.EXECUTOR_ID)) {
handler.command().addParameter("--debug");
}
handler.start();
final OSProcessHandler result = handler.getHandler();
showProgress(result, title);
return result;
}
use of com.intellij.execution.process.OSProcessHandler in project intellij-plugins by JetBrains.
the class DartPubActionBase method doPerformPubAction.
private static void doPerformPubAction(@NotNull final Module module, @NotNull final VirtualFile pubspecYamlFile, @NotNull final GeneralCommandLine command, @NotNull final String actionTitle) {
FileDocumentManager.getInstance().saveAllDocuments();
try {
if (ourInProgress.compareAndSet(false, true)) {
command.withEnvironment(PUB_ENV_VAR_NAME, getPubEnvValue());
final OSProcessHandler processHandler = new OSProcessHandler(command);
processHandler.addProcessListener(new ProcessAdapter() {
@Override
public void processTerminated(final ProcessEvent event) {
ourInProgress.set(false);
ApplicationManager.getApplication().invokeLater(() -> {
if (!module.isDisposed()) {
DartProjectComponent.excludeBuildAndPackagesFolders(module, pubspecYamlFile);
// refresh later than exclude, otherwise IDE may start indexing excluded folders
VfsUtil.markDirtyAndRefresh(true, true, true, pubspecYamlFile.getParent());
if (DartSdkLibUtil.isDartSdkEnabled(module)) {
DartAnalysisServerService.getInstance(module.getProject()).serverReadyForRequest(module.getProject());
}
}
});
}
});
showPubOutputConsole(module, command, processHandler, pubspecYamlFile, actionTitle);
}
} catch (ExecutionException e) {
ourInProgress.set(false);
// may be better show it in Messages tool window console?
Notifications.Bus.notify(new Notification(GROUP_DISPLAY_ID, actionTitle, DartBundle.message("dart.pub.exception", e.getMessage()), NotificationType.ERROR));
}
}
use of com.intellij.execution.process.OSProcessHandler in project intellij-plugins by JetBrains.
the class PubServerService method createProcessHandler.
@Override
@Nullable
protected OSProcessHandler createProcessHandler(@NotNull final Project project, final int port) throws ExecutionException {
final DartSdk dartSdk = DartSdk.getDartSdk(project);
if (dartSdk == null)
return null;
final GeneralCommandLine commandLine = new GeneralCommandLine().withWorkDirectory(firstServedDir.getParent().getPath());
commandLine.setExePath(FileUtil.toSystemDependentName(DartSdkUtil.getPubPath(dartSdk)));
commandLine.addParameter("serve");
commandLine.addParameter(firstServedDir.getName());
commandLine.addParameter("--port=" + String.valueOf(port));
commandLine.withEnvironment(DartPubActionBase.PUB_ENV_VAR_NAME, DartPubActionBase.getPubEnvValue());
final OSProcessHandler processHandler = new OSProcessHandler(commandLine);
processHandler.addProcessListener(new PubServeOutputListener(project));
return processHandler;
}
use of com.intellij.execution.process.OSProcessHandler in project intellij-community by JetBrains.
the class BaseJavaApplicationCommandLineState method startProcess.
@NotNull
@Override
protected OSProcessHandler startProcess() throws ExecutionException {
OSProcessHandler handler = new KillableColoredProcessHandler(createCommandLine());
ProcessTerminatedListener.attach(handler);
JavaRunConfigurationExtensionManager.getInstance().attachExtensionsToProcess(getConfiguration(), handler, getRunnerSettings());
return handler;
}
use of com.intellij.execution.process.OSProcessHandler in project intellij-community by JetBrains.
the class GroovyScriptRunConfiguration method getState.
@Override
public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment environment) throws ExecutionException {
final VirtualFile scriptFile = ScriptFileUtil.findScriptFileByPath(getScriptPath());
if (scriptFile == null)
return null;
final GroovyScriptRunner scriptRunner = getScriptRunner();
if (scriptRunner == null)
return null;
return new JavaCommandLineState(environment) {
@NotNull
@Override
protected OSProcessHandler startProcess() throws ExecutionException {
final OSProcessHandler handler = super.startProcess();
handler.setShouldDestroyProcessRecursively(true);
if (scriptRunner.shouldRefreshAfterFinish()) {
handler.addProcessListener(new ProcessAdapter() {
@Override
public void processTerminated(ProcessEvent event) {
if (!ApplicationManager.getApplication().isDisposed()) {
VirtualFileManager.getInstance().asyncRefresh(null);
}
}
});
}
return handler;
}
@Override
protected JavaParameters createJavaParameters() throws ExecutionException {
final Module module = getModule();
final boolean tests = ProjectRootManager.getInstance(getProject()).getFileIndex().isInTestSourceContent(scriptFile);
String jrePath = isAlternativeJrePathEnabled() ? getAlternativeJrePath() : null;
JavaParameters params = new JavaParameters();
params.setUseClasspathJar(true);
params.setDefaultCharset(getProject());
params.setJdk(module == null ? JavaParametersUtil.createProjectJdk(getProject(), jrePath) : JavaParametersUtil.createModuleJdk(module, !tests, jrePath));
configureConfiguration(params, new CommonProgramRunConfigurationParametersDelegate(GroovyScriptRunConfiguration.this) {
@Nullable
@Override
public String getProgramParameters() {
return null;
}
});
scriptRunner.configureCommandLine(params, module, tests, scriptFile, GroovyScriptRunConfiguration.this);
return params;
}
};
}
Aggregations