Fixing NullPointerException when there is a diagnostic with no associated source file.
According to javax/tools/Diagnostic.java: not all diagnostics are associated with a position or a file.
Change on 2018/05/23 by antoniocortes
@@ -119,7 +119,7 @@ public class ErrorUtil implements DiagnosticListener<JavaFileObject> {
return;
}
String msg;
- if (CLANG_STYLE_ERROR_MSG) {
+ if (CLANG_STYLE_ERROR_MSG && diagnostic.getSource() != null) {
msg = String.format("error: %s:%d: %s", diagnostic.getSource().getName(),
diagnostic.getLineNumber(), diagnostic.getMessage(null).trim());
} else {
