public void apply(ProcessHandler listener) { for (Pair<ProcessEvent, Key> pair : myHistory) { listener.notifyTextAvailable(pair.getFirst().getText(), pair.getSecond()); } } }
@Override public void onCancel() { doNotStart = true; ProcessHandler handler = getProcessHandler(); if (handler != null) { handler.destroyProcess(); } }
@Override public void startNotify() { if (myShowGoEnvVariables) { GoRunUtil.printGoEnvVariables(finalCommandLine, this); } super.startNotify(); } };
@Override public void processTerminated(@NotNull ProcessEvent event) { super.processTerminated(event); boolean success = event.getExitCode() == 0 && myProcessOutput.getStderr().isEmpty(); boolean nothingToShow = myProcessOutput.getStdout().isEmpty() && myProcessOutput.getStderr().isEmpty(); boolean cancelledByUser = (event.getExitCode() == -1 || event.getExitCode() == 2) && nothingToShow; result.set(success); if (success) { if (myShowNotificationsOnSuccess) { showNotification("Finished successfully", NotificationType.INFORMATION); } } else if (cancelledByUser) { if (myShowNotificationsOnError) { showNotification("Interrupted", NotificationType.WARNING); } } else if (myShowOutputOnError) { ApplicationManager.getApplication().invokeLater(() -> showOutput(myProcessHandler, historyProcessListener)); } } };
@NotNull @Override protected ProcessHandler startProcess() throws ExecutionException { GoExecutor executor = patchExecutor(createCommonExecutor()); GeneralCommandLine commandLine = executor.withParameterString(myConfiguration.getParams()).createCommandLine(); KillableColoredProcessHandler handler = new KillableColoredProcessHandler(commandLine, true); ProcessTerminatedListener.attach(handler); return handler; }
@NotNull public static com.intellij.execution.process.ProcessOutput execute(@NotNull GeneralCommandLine cmd, int timeout) throws ExecutionException { CapturingProcessHandler processHandler = new CapturingProcessHandler(cmd.createProcess()); return timeout < 0 ? processHandler.runProcess() : processHandler.runProcess(timeout); }
@NotNull @Override protected ProcessHandler startProcess() throws ExecutionException { ProcessHandler processHandler = super.startProcess(); processHandler.addProcessListener(new ProcessAdapter() { @Override public void startNotified(ProcessEvent event) { if (myHistoryProcessHandler != null) { myHistoryProcessHandler.apply(processHandler); } } }); return processHandler; }
private void onTextAvailableInAny(@NotNull ProcessEvent event, @NotNull Key outputType) { String eventText = event.getText(); if (!isBlank(eventText)) { text.append(eventText); } }
private void showOutput(@NotNull OSProcessHandler originalHandler, @NotNull GoHistoryProcessListener historyProcessListener) { if (myShowOutputOnError) { BaseOSProcessHandler outputHandler = new KillableColoredProcessHandler(originalHandler.getProcess(), null); RunContentExecutor runContentExecutor = new RunContentExecutor(myProject, outputHandler) .withTitle(getPresentableName()) .withActivateToolWindow(myShowOutputOnError) .withFilter(new GoConsoleFilter(myProject, myModule, myWorkDirectory != null ? VfsUtilCore.pathToUrl(myWorkDirectory) : null)); Disposer.register(myProject, runContentExecutor); runContentExecutor.run(); historyProcessListener.apply(outputHandler); } if (myShowNotificationsOnError) { showNotification("Failed to run", NotificationType.ERROR); } }
public void testIssue521() throws ExecutionException { assertEquals( -1, ProcessOutput .getProcessOutput( 1, null, "/exe-path", new String[0] ) .getExitCode() ); } }
@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);
public static void printGoEnvVariables(@NotNull GeneralCommandLine commandLine, @NotNull ProcessHandler handler) { Map<String, String> environment = commandLine.getEnvironment(); handler.notifyTextAvailable("GOROOT=" + StringUtil.nullize(environment.get(GoConstants.GO_ROOT)) + '\n', ProcessOutputTypes.SYSTEM); handler.notifyTextAvailable("GOPATH=" + StringUtil.nullize(environment.get(GoConstants.GO_PATH)) + '\n', ProcessOutputTypes.SYSTEM); } }
@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(); } } } });
@Override public void processTerminated(@NotNull ProcessEvent event) { super.processTerminated(event); boolean success = event.getExitCode() == 0 && myProcessOutput.getStderr().isEmpty(); boolean nothingToShow = myProcessOutput.getStdout().isEmpty() && myProcessOutput.getStderr().isEmpty(); boolean cancelledByUser = (event.getExitCode() == -1 || event.getExitCode() == 2) && nothingToShow; result.set(success); if (success) { if (myShowNotificationsOnSuccess) { showNotification("Finished successfully", NotificationType.INFORMATION); } } else if (cancelledByUser) { if (myShowNotificationsOnError) { showNotification("Interrupted", NotificationType.WARNING); } } else if (myShowOutputOnError) { ApplicationManager.getApplication().invokeLater(() -> showOutput(myProcessHandler, historyProcessListener)); } } };
public void apply(ProcessHandler listener) { for (Pair<ProcessEvent, Key> pair : myHistory) { listener.notifyTextAvailable(pair.getFirst().getText(), pair.getSecond()); } } }
@NotNull @Override protected ProcessHandler startProcess() throws ExecutionException { BallerinaExecutor executor = patchExecutor(createCommonExecutor()); // We only need to set parameters. GeneralCommandLine commandLine = executor.withParameterString(myConfiguration.getParams()).createCommandLine(); KillableColoredProcessHandler handler = new KillableColoredProcessHandler(commandLine, true); ProcessTerminatedListener.attach(handler); return handler; }
@NotNull @Override protected ProcessHandler startProcess() throws ExecutionException { ProcessHandler processHandler = super.startProcess(); processHandler.addProcessListener(new ProcessAdapter() { @Override public void startNotified(ProcessEvent event) { if (myHistoryProcessHandler != null) { myHistoryProcessHandler.apply(processHandler); } } }); return processHandler; }
@Override public void onCancel() { doNotStart = true; ProcessHandler handler = getProcessHandler(); if (handler != null) { handler.destroyProcess(); } }
@Override public void startNotify() { if (myShowBallerinaEnvVariables) { BallerinaRunUtil.printBallerinaEnvVariables(finalCommandLine, this); } super.startNotify(); } };
@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; }