| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
| 6 import "package:compiler/src/parser/node_listener.dart"; | 6 import "package:compiler/src/parser/node_listener.dart"; |
| 7 import "package:compiler/src/parser/parser.dart"; | 7 import "package:compiler/src/parser/parser.dart"; |
| 8 import "package:compiler/src/scanner/string_scanner.dart"; | 8 import "package:compiler/src/scanner/string_scanner.dart"; |
| 9 import "package:compiler/src/tokens/token.dart"; | 9 import "package:compiler/src/tokens/token.dart"; |
| 10 import "package:compiler/src/tree/tree.dart"; | 10 import "package:compiler/src/tree/tree.dart"; |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 StringScanner scanner = new StringScanner.fromString(source); | 92 StringScanner scanner = new StringScanner.fromString(source); |
| 93 Token beginToken = scanner.tokenize(); | 93 Token beginToken = scanner.tokenize(); |
| 94 NodeListener listener = new NodeListener(diagnosticListener, element); | 94 NodeListener listener = new NodeListener(diagnosticListener, element); |
| 95 Parser parser = new Parser(listener); | 95 Parser parser = new Parser(listener); |
| 96 parser.parseUnit(beginToken); | 96 parser.parseUnit(beginToken); |
| 97 Node node = listener.popNode(); | 97 Node node = listener.popNode(); |
| 98 Expect.isTrue(listener.nodes.isEmpty); | 98 Expect.isTrue(listener.nodes.isEmpty); |
| 99 return unparse(node); | 99 return unparse(node); |
| 100 } | 100 } |
| 101 | 101 |
| 102 class MessageCollector extends DiagnosticListener { | 102 class MessageCollector extends DiagnosticReporter { |
| 103 List<String> messages; | 103 List<String> messages; |
| 104 MessageCollector() { | 104 MessageCollector() { |
| 105 messages = []; | 105 messages = []; |
| 106 } | 106 } |
| 107 void internalError(node, String reason) { | 107 void internalError(node, String reason) { |
| 108 messages.add(reason); | 108 messages.add(reason); |
| 109 throw reason; | 109 throw reason; |
| 110 } | 110 } |
| 111 | 111 |
| 112 void log(message) { | 112 void log(message) { |
| 113 messages.add(message); | 113 messages.add(message); |
| 114 } | 114 } |
| 115 | 115 |
| 116 noSuchMethod(Invocation invocation) => throw 'unsupported operation'; | 116 noSuchMethod(Invocation invocation) => throw 'unsupported operation'; |
| 117 } | 117 } |
| OLD | NEW |