use of com.intellij.execution.process.ProcessAdapter in project go-lang-idea-plugin by go-lang-plugin-org.
the class GoBuildingRunner method prepare.
@NotNull
@Override
protected Promise<RunProfileStarter> prepare(@NotNull ExecutionEnvironment environment, @NotNull RunProfileState state) throws ExecutionException {
File outputFile = getOutputFile(environment, (GoApplicationRunningState) state);
FileDocumentManager.getInstance().saveAllDocuments();
AsyncPromise<RunProfileStarter> buildingPromise = new AsyncPromise<>();
GoHistoryProcessListener historyProcessListener = new GoHistoryProcessListener();
((GoApplicationRunningState) state).createCommonExecutor().withParameters("build").withParameterString(((GoApplicationRunningState) state).getGoBuildParams()).withParameters("-o", outputFile.getAbsolutePath()).withParameters(((GoApplicationRunningState) state).isDebug() ? new String[] { "-gcflags", "-N -l" } : ArrayUtil.EMPTY_STRING_ARRAY).withParameters(((GoApplicationRunningState) state).getTarget()).disablePty().withPresentableName("go build").withProcessListener(historyProcessListener).withProcessListener(new ProcessAdapter() {
@Override
public void processTerminated(ProcessEvent event) {
super.processTerminated(event);
boolean compilationFailed = event.getExitCode() != 0;
if (((GoApplicationRunningState) state).isDebug()) {
buildingPromise.setResult(new MyDebugStarter(outputFile.getAbsolutePath(), historyProcessListener, compilationFailed));
} else {
buildingPromise.setResult(new MyRunStarter(outputFile.getAbsolutePath(), historyProcessListener, compilationFailed));
}
}
}).executeWithProgress(false);
return buildingPromise;
}
use of com.intellij.execution.process.ProcessAdapter in project go-lang-idea-plugin by go-lang-plugin-org.
the class GoApplicationRunningState method startProcess.
@NotNull
@Override
protected ProcessHandler startProcess() throws ExecutionException {
ProcessHandler processHandler = myCompilationFailed ? new GoNopProcessHandler() : super.startProcess();
processHandler.addProcessListener(new ProcessAdapter() {
@Override
public void startNotified(ProcessEvent event) {
if (myHistoryProcessHandler != null) {
myHistoryProcessHandler.apply(processHandler);
}
}
@Override
public void processTerminated(ProcessEvent event) {
super.processTerminated(event);
if (StringUtil.isEmpty(myConfiguration.getOutputFilePath())) {
File file = new File(myOutputFilePath);
if (file.exists()) {
//noinspection ResultOfMethodCallIgnored
file.delete();
}
}
}
});
return processHandler;
}
use of com.intellij.execution.process.ProcessAdapter in project intellij-elixir by KronicDeth.
the class MixBuilder method runMix.
private static void runMix(@NotNull String elixirPath, @NotNull String mixPath, @Nullable String contentRootPath, boolean addDebugInfo, @NotNull CompileContext context) throws ProjectBuildException {
GeneralCommandLine commandLine = new GeneralCommandLine();
commandLine.withWorkDirectory(contentRootPath);
commandLine.setExePath(elixirPath);
commandLine.addParameter(mixPath);
commandLine.addParameter("compile");
if (!addDebugInfo) {
commandLine.addParameter("--no-debug-info");
}
Process process;
try {
process = commandLine.createProcess();
} catch (ExecutionException e) {
throw new ProjectBuildException("Failed to run mix.", e);
}
BaseOSProcessHandler handler = new BaseOSProcessHandler(process, commandLine.getCommandLineString(), Charset.defaultCharset());
ProcessAdapter adapter = new ElixirCompilerProcessAdapter(context, NAME, commandLine.getWorkDirectory().getPath());
handler.addProcessListener(adapter);
handler.startNotify();
handler.waitFor();
}
use of com.intellij.execution.process.ProcessAdapter in project intellij-community by JetBrains.
the class PydevConsoleRunnerImpl method connect.
private void connect(final String[] statements2execute) {
if (handshake()) {
ApplicationManager.getApplication().invokeLater(() -> {
// Propagate console communication to language console
final PythonConsoleView consoleView = myConsoleView;
consoleView.setConsoleCommunication(myPydevConsoleCommunication);
consoleView.setSdk(mySdk);
consoleView.setExecutionHandler(myConsoleExecuteActionHandler);
myProcessHandler.addProcessListener(new ProcessAdapter() {
@Override
public void onTextAvailable(ProcessEvent event, Key outputType) {
consoleView.print(event.getText(), outputType);
}
});
if (myEnableAfterConnection) {
enableConsoleExecuteAction();
}
for (String statement : statements2execute) {
consoleView.executeStatement(statement + "\n", ProcessOutputTypes.SYSTEM);
}
fireConsoleInitializedEvent(consoleView);
consoleView.initialized();
});
} else {
myConsoleView.print("Couldn't connect to console process.", ProcessOutputTypes.STDERR);
myProcessHandler.destroyProcess();
myConsoleView.setEditable(false);
}
}
use of com.intellij.execution.process.ProcessAdapter in project intellij-community by JetBrains.
the class PydevConsoleRunnerImpl method initAndRun.
private void initAndRun() throws ExecutionException {
// Create Server process
final Process process = createProcess();
UIUtil.invokeLaterIfNeeded(() -> {
// Init console view
myConsoleView = createConsoleView();
if (myConsoleView != null) {
((JComponent) myConsoleView).setBorder(new SideBorder(JBColor.border(), SideBorder.LEFT));
}
myProcessHandler = createProcessHandler(process);
myConsoleExecuteActionHandler = createExecuteActionHandler();
ProcessTerminatedListener.attach(myProcessHandler);
PythonConsoleView consoleView = myConsoleView;
myProcessHandler.addProcessListener(new ProcessAdapter() {
@Override
public void processTerminated(ProcessEvent event) {
consoleView.setEditable(false);
}
});
// Attach to process
myConsoleView.attachToProcess(myProcessHandler);
createContentDescriptorAndActions();
// Run
myProcessHandler.startNotify();
});
}
Aggregations