OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 package com.google.dart.compiler; | 5 package com.google.dart.compiler; |
6 | 6 |
7 import java.io.PrintStream; | 7 import java.io.PrintStream; |
8 | 8 |
9 /** | 9 /** |
10 * An error formatter that simply prints the file name with the line and column | 10 * An error formatter that simply prints the file name with the line and column |
11 * location. | 11 * location. |
12 */ | 12 */ |
13 public class DefaultErrorFormatter implements ErrorFormatter { | 13 public class DefaultErrorFormatter implements ErrorFormatter { |
14 protected PrintStream outputStream = System.err; | 14 protected final PrintStream outputStream; |
15 | 15 |
16 public void setOutputStream(PrintStream outputStream) { | 16 public DefaultErrorFormatter(PrintStream outputStream) { |
17 this.outputStream = outputStream; | 17 this.outputStream = outputStream; |
18 } | 18 } |
19 | 19 |
20 @Override | 20 @Override |
21 public void format(DartCompilationError event) { | 21 public void format(DartCompilationError event) { |
22 outputStream.printf("%s:%d:%d: %s\n", | 22 outputStream.printf("%s:%d:%d: %s\n", |
23 (event.getSource() != null) | 23 (event.getSource() != null) |
24 ? event.getSource().getName() : "<unknown-source-file>", | 24 ? event.getSource().getName() : "<unknown-source-file>", |
25 event.getLineNumber(), | 25 event.getLineNumber(), |
26 event.getColumnNumber(), | 26 event.getColumnNumber(), |
27 event.getMessage()); | 27 event.getMessage()); |
28 } | 28 } |
29 } | 29 } |
OLD | NEW |