in src/main/java/org/jetbrains/uncrustify/UncrustifyAsyncFormattingService.java [86:117]
protected void format(@NotNull String configPath, @NotNull String filename) {
String text = formattingRequest.getDocumentText();
try {
uncrustifyHandler = UncrustifyExecutable.executeWithProcessListener(
getSettings().executablePath,
List.of("-c", configPath, "--assume", filename),
text,
new CapturingProcessAdapter() {
@Override
public void processTerminated(@NotNull ProcessEvent event) {
super.processTerminated(event);
int exitCode = getOutput().getExitCode();
if (exitCode != 0) {
log.warn(String.format("uncrustify exitCode: %d", exitCode));
log.warn(getOutput().getStdout());
log.warn(getOutput().getStderr());
formattingRequest.onError(UncrustifyBundle.message("uncrustify.process.error.title"),
String.format(UncrustifyBundle.message("uncrustify.process.error.exitCode"), exitCode));
} else {
formattingRequest.onTextReady(getOutput().getStdout());
}
}
},
false);
} catch (ExecutionException e) {
log.warn("uncrustify service failed: " + e.getMessage());
log.debug(e);
formattingRequest.onError(UncrustifyBundle.message("uncrustify.process.error.title"),
UncrustifyBundle.message("uncrustify.process.error.generalException"));
}
}