use of com.intellij.execution.process.ProcessEvent 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.ProcessEvent 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.ProcessEvent in project buck by facebook.
the class BuckToGeneralTestEventsConverter method onStartTesting.
@Override
public void onStartTesting() {
mConnection = mProject.getMessageBus().connect();
mConnection.subscribe(TestResultsAvailableConsumer.BUCK_TEST_RESULTS_AVAILABLE, this);
mConnection.subscribe(TestRunCompleteConsumer.BUCK_TEST_RUN_COMPLETE, this);
mConnection.subscribe(TestRunStartedConsumer.BUCK_TEST_RUN_STARTED, this);
mConnection.subscribe(BuckBuildStartConsumer.BUCK_BUILD_START, this);
mConnection.subscribe(BuckBuildEndConsumer.BUCK_BUILD_END, this);
mConnection.subscribe(CompilerErrorConsumer.COMPILER_ERROR_CONSUMER, this);
myHandler.addProcessListener(new ProcessAdapter() {
@Override
public void processTerminated(ProcessEvent event) {
mConnection.disconnect();
}
});
}
use of com.intellij.execution.process.ProcessEvent in project intellij-leiningen-plugin by derkork.
the class LeiningenRunConfigurationType method runConfiguration.
public static void runConfiguration(Project project, LeiningenRunnerParameters params, DataContext context) {
RunnerAndConfigurationSettings configSettings = createRunnerAndConfigurationSettings(params, project);
ProgramRunner runner = RunnerRegistry.getInstance().findRunnerById(DefaultRunExecutor.EXECUTOR_ID);
Executor executor = DefaultRunExecutor.getRunExecutorInstance();
ExecutionEnvironment env = new ExecutionEnvironment(executor, runner, configSettings, project);
try {
runner.execute(env, new ProgramRunner.Callback() {
public void processStarted(RunContentDescriptor runContentDescriptor) {
final ProcessHandler runContentDescriptorProcessHandler = runContentDescriptor.getProcessHandler();
if (runContentDescriptorProcessHandler != null) {
runContentDescriptorProcessHandler.addProcessListener(new ProcessAdapter() {
@Override
public void processTerminated(ProcessEvent event) {
LocalFileSystem.getInstance().refreshWithoutFileWatcher(true);
}
});
}
}
});
} catch (ExecutionException e) {
}
}
use of com.intellij.execution.process.ProcessEvent in project android by JetBrains.
the class EmulatorProcessHandler method startNotify.
@Override
public void startNotify() {
// Wait for both the stdout and stderr reader threads to finish and then indicate that the process has terminated
addProcessListener(new ProcessAdapter() {
@Override
public void startNotified(final ProcessEvent event) {
try {
String presentableName = CommandLineUtil.extractPresentableName(myCommandLine.getCommandLineString());
final BaseDataReader stdoutReader = new EmulatorOutputReader(myProcess.getInputStream(), ProcessOutputTypes.STDOUT, presentableName);
final BaseDataReader stderrReader = new EmulatorOutputReader(myProcess.getErrorStream(), ProcessOutputTypes.STDERR, presentableName);
executeTask(() -> {
try {
stderrReader.waitFor();
stdoutReader.waitFor();
} catch (InterruptedException ignore) {
} finally {
notifyProcessTerminated(0);
}
});
} finally {
removeProcessListener(this);
}
}
});
super.startNotify();
}
Aggregations