use of com.intellij.execution.process.ProcessOutput in project intellij-plugins by JetBrains.
the class TsLintExternalAnnotator method createGlobalErrorMessage.
@Nullable
private static JSLinterAnnotationResult<TsLintState> createGlobalErrorMessage(@NotNull TsLinterInput collectedInfo, @Nullable VirtualFile config, @Nullable String error) {
if (!StringUtil.isEmptyOrSpaces(error)) {
final ProcessOutput output = new ProcessOutput();
output.appendStderr(error);
final IntentionAction detailsAction = JSLinterUtil.createDetailsAction(collectedInfo.getProject(), collectedInfo.getVirtualFile(), null, output, null);
final JSLinterFileLevelAnnotation annotation = new JSLinterFileLevelAnnotation(error, detailsAction);
return JSLinterAnnotationResult.create(collectedInfo, annotation, config);
}
return null;
}
use of com.intellij.execution.process.ProcessOutput in project flutter-intellij by flutter.
the class FlutterSettingsConfigurable method updateVersionText.
private void updateVersionText() {
final FlutterSdk sdk = FlutterSdk.forPath(getSdkPathText());
if (sdk == null) {
myVersionLabel.setText("");
return;
}
final ModalityState modalityState = ModalityState.current();
sdk.flutterVersion().start((ProcessOutput output) -> {
final String stdout = output.getStdout();
final String htmlText = "<html>" + StringUtil.replace(StringUtil.escapeXml(stdout.trim()), "\n", "<br/>") + "</html>";
ApplicationManager.getApplication().invokeLater(() -> updateVersionTextIfCurrent(sdk, htmlText), modalityState);
}, null);
}
use of com.intellij.execution.process.ProcessOutput in project teamcity-powershell by JetBrains.
the class DetectionRunner method runProcess.
private static ProcessOutput runProcess(@NotNull final GeneralCommandLine cl) throws ExecutionException {
final CapturingProcessHandler handler = new CapturingProcessHandler(cl.createProcess(), Charset.forName("UTF-8"));
final ProcessOutput result = handler.runProcess(20000);
if (result.isTimeout()) {
throw new ExecutionException("Process execution of [" + cl.getCommandLineString() + "] has timed out");
}
final String errorOutput = result.getStderr();
if (!StringUtil.isEmptyOrSpaces(errorOutput)) {
throw new ExecutionException(errorOutput);
}
return result;
}
use of com.intellij.execution.process.ProcessOutput in project Perl5-IDEA by Camelcade.
the class PerlFormatWithPerlTidyAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent event) {
if (isEnabled(event)) {
final PsiFile file = PerlActionUtil.getPsiFileFromEvent(event);
if (file == null) {
return;
}
final Project project = file.getProject();
final Document document = file.getViewProvider().getDocument();
if (document == null) {
return;
}
final VirtualFile virtualFile = file.getVirtualFile();
if (virtualFile == null) {
return;
}
FileDocumentManager.getInstance().saveDocument(document);
new Task.Backgroundable(project, PerlBundle.message("perl.tidy.formatting"), false) {
@Override
public void run(@NotNull ProgressIndicator indicator) {
try {
GeneralCommandLine perlTidyCommandLine = getPerlTidyCommandLine(project);
final Process process = perlTidyCommandLine.createProcess();
final OutputStream outputStream = process.getOutputStream();
ApplicationManager.getApplication().executeOnPooledThread(() -> {
try {
final byte[] sourceBytes = virtualFile.contentsToByteArray();
outputStream.write(sourceBytes);
outputStream.close();
} catch (IOException e) {
Notifications.Bus.notify(new Notification(PERL_TIDY_GROUP, PerlBundle.message("perl.action.perl.tidy.formatting.error.title"), e.getMessage(), NotificationType.ERROR));
}
});
final CapturingProcessHandler processHandler = new CapturingProcessHandler(process, virtualFile.getCharset(), perlTidyCommandLine.getCommandLineString());
ProcessOutput processOutput = processHandler.runProcess();
final List<String> stdoutLines = processOutput.getStdoutLines(false);
List<String> stderrLines = processOutput.getStderrLines();
if (stderrLines.isEmpty()) {
WriteCommandAction.runWriteCommandAction(project, () -> {
document.setText(StringUtil.join(stdoutLines, "\n"));
PsiDocumentManager.getInstance(project).commitDocument(document);
});
} else {
Notifications.Bus.notify(new Notification(PERL_TIDY_GROUP, PerlBundle.message("perl.action.perl.tidy.formatting.error.title"), StringUtil.join(stderrLines, "<br>"), NotificationType.ERROR));
}
} catch (ExecutionException e) {
Notifications.Bus.notify(new Notification(PERL_TIDY_GROUP, PerlBundle.message("perl.action.perl.tidy.running.error.title"), PerlBundle.message("perl.action.perl.tidy.running.error.message", e.getMessage().replaceAll("\\n", "<br/>")), NotificationType.ERROR).addAction(new DumbAwareAction(PerlBundle.message("perl.configure")) {
@Override
public void actionPerformed(AnActionEvent e) {
Notification.get(e).expire();
Perl5SettingsConfigurable.open(file);
}
}));
}
}
}.queue();
}
}
use of com.intellij.execution.process.ProcessOutput in project Perl5-IDEA by Camelcade.
the class PerlCoverageRunner method doLoadCoverageData.
@Nullable
private static ProjectData doLoadCoverageData(@NotNull File sessionDataFile, @NotNull PerlCoverageSuite perlCoverageSuite) {
Project project = perlCoverageSuite.getProject();
GeneralCommandLine perlCommandLine = ReadAction.compute(() -> {
if (project.isDisposed()) {
return null;
}
VirtualFile coverFile = PerlRunUtil.findLibraryScriptWithNotification(project, COVER, COVER_LIB);
if (coverFile == null) {
return null;
}
String libRoot = PerlPluginUtil.getPluginPerlLibRoot();
if (libRoot == null) {
return null;
}
GeneralCommandLine commandLine = PerlRunUtil.getPerlCommandLine(project, coverFile, "-I" + FileUtil.toSystemIndependentName(libRoot));
if (commandLine == null) {
// fixme should be a notification
return null;
}
commandLine.addParameters("--silent", "--nosummary", "-report", "camelcade", sessionDataFile.getAbsolutePath());
return commandLine;
});
if (perlCommandLine == null) {
return null;
}
try {
LOG.info("Loading coverage by: " + perlCommandLine.getCommandLineString());
ProcessOutput output = ExecUtil.execAndGetOutput(perlCommandLine);
if (output.getExitCode() != 0) {
String errorMessage = output.getStderr();
if (StringUtil.isEmpty(errorMessage)) {
errorMessage = output.getStdout();
}
if (!StringUtil.isEmpty(errorMessage)) {
showError(project, errorMessage);
}
return null;
}
String stdout = output.getStdout();
if (StringUtil.isEmpty(stdout)) {
return null;
}
try {
PerlFileData[] filesData = new Gson().fromJson(stdout, PerlFileData[].class);
if (filesData != null) {
return parsePerlFileData(filesData);
}
} catch (JsonParseException e) {
showError(project, e.getMessage());
LOG.warn("Error parsing JSON", e);
}
} catch (ExecutionException e) {
showError(project, e.getMessage());
LOG.warn("Error loading coverage", e);
}
return null;
}
Aggregations