@@ -183,11 +183,18 @@ private void checkDiagnosticCount(
183
183
}
184
184
185
185
private static String messageListing (
186
- Iterable <? extends Diagnostic <?>> diagnostics , String headingFormat , Object ... formatArgs ) {
186
+ Iterable <? extends Diagnostic <? extends JavaFileObject >> diagnostics ,
187
+ String headingFormat ,
188
+ Object ... formatArgs ) {
187
189
StringBuilder listing =
188
190
new StringBuilder (String .format (headingFormat , formatArgs )).append ('\n' );
189
- for (Diagnostic <?> diagnostic : diagnostics ) {
190
- listing .append (diagnostic .getMessage (null )).append ('\n' );
191
+ for (Diagnostic <? extends JavaFileObject > diagnostic : diagnostics ) {
192
+ listing .append (
193
+ String .format (
194
+ "%s:%d - %s\n " ,
195
+ sourceFileName (diagnostic ),
196
+ diagnostic .getLineNumber (),
197
+ diagnostic .getMessage (null )));
191
198
}
192
199
return listing .toString ();
193
200
}
@@ -416,15 +423,17 @@ private ImmutableList<Diagnostic<? extends JavaFileObject>> findDiagnosticsInFil
416
423
}
417
424
418
425
private ImmutableSet <String > sourceFilesWithDiagnostics () {
419
- return mapDiagnostics (
420
- diagnostic ->
421
- diagnostic .getSource () == null
422
- ? "(no associated file)"
423
- : diagnostic .getSource ().getName ())
426
+ return mapDiagnostics (CompilationSubject ::sourceFileName )
424
427
.collect (toImmutableSet ());
425
428
}
426
429
}
427
430
431
+ private static String sourceFileName (Diagnostic <? extends JavaFileObject > diagnostic ) {
432
+ return diagnostic .getSource () == null
433
+ ? "(no associated file)"
434
+ : diagnostic .getSource ().getName ();
435
+ }
436
+
428
437
/** An object that can list the lines in a file. */
429
438
static final class LinesInFile {
430
439
private final JavaFileObject file ;
0 commit comments