@@ -183,11 +183,18 @@ private void checkDiagnosticCount(
183183 }
184184
185185 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 ) {
187189 StringBuilder listing =
188190 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 )));
191198 }
192199 return listing .toString ();
193200 }
@@ -416,15 +423,17 @@ private ImmutableList<Diagnostic<? extends JavaFileObject>> findDiagnosticsInFil
416423 }
417424
418425 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 )
424427 .collect (toImmutableSet ());
425428 }
426429 }
427430
431+ private static String sourceFileName (Diagnostic <? extends JavaFileObject > diagnostic ) {
432+ return diagnostic .getSource () == null
433+ ? "(no associated file)"
434+ : diagnostic .getSource ().getName ();
435+ }
436+
428437 /** An object that can list the lines in a file. */
429438 static final class LinesInFile {
430439 private final JavaFileObject file ;
0 commit comments