A super simplistic error handler which is used for writing error messages to a given output stream (e.g. stdout). @author David J. Pearce
| 329 | * |
| 330 | */ |
| 331 | public static class PrintStreamErrorHandler implements MailBox<SyntaxError> { |
| 332 | private final PrintStream output; |
| 333 | |
| 334 | public PrintStreamErrorHandler(PrintStream output) { |
| 335 | this.output = output; |
| 336 | } |
| 337 | |
| 338 | @Override |
| 339 | public void send(SyntaxError marker) { |
| 340 | // Identify enclosing source file |
| 341 | String filename = marker.getSource().toString() + ".whiley"; |
| 342 | // Determine the source-file span for the given syntactic marker. |
| 343 | Syntactic.Span span = marker.getTarget().getAncestor(AbstractCompilationUnit.Attribute.Span.class); |
| 344 | // print the error message |
| 345 | output.println(filename + "|" + span.getStart() + "|" + span.getEnd() + "|" + marker.getErrorCode() + "|" |
| 346 | + marker.getMessage().replace("\n", "\\n")); |
| 347 | } |
| 348 | } |
| 349 | } |
nothing calls this directly
no outgoing calls
no test coverage detected