| 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 library parser_helper; | 5 library parser_helper; |
| 6 | 6 |
| 7 import "package:expect/expect.dart"; | 7 import "package:expect/expect.dart"; |
| 8 | 8 |
| 9 import "package:compiler/src/elements/elements.dart"; | 9 import "package:compiler/src/elements/elements.dart"; |
| 10 import "package:compiler/src/tree/tree.dart"; | 10 import "package:compiler/src/tree/tree.dart"; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 throw 'unsupported operation'; | 35 throw 'unsupported operation'; |
| 36 } | 36 } |
| 37 | 37 |
| 38 void reportMessage(SourceSpan span, Message message, kind) { | 38 void reportMessage(SourceSpan span, Message message, kind) { |
| 39 log(message); | 39 log(message); |
| 40 } | 40 } |
| 41 | 41 |
| 42 void reportFatalError(Spannable node, | 42 void reportFatalError(Spannable node, |
| 43 MessageKind errorCode, | 43 MessageKind errorCode, |
| 44 [Map arguments]) { | 44 [Map arguments]) { |
| 45 log(new Message(errorCode, arguments, false)); | 45 log(new Message(MessageTemplate.TEMPLATES[errorCode], arguments, false)); |
| 46 } | 46 } |
| 47 | 47 |
| 48 void reportError(Spannable node, MessageKind errorCode, [Map arguments]) { | 48 void reportError(Spannable node, MessageKind errorCode, [Map arguments]) { |
| 49 log(new Message(errorCode, arguments, false)); | 49 log(new Message(MessageTemplate.TEMPLATES[errorCode], arguments, false)); |
| 50 } | 50 } |
| 51 | 51 |
| 52 void reportWarning(Spannable node, MessageKind errorCode, [Map arguments]) { | 52 void reportWarning(Spannable node, MessageKind errorCode, [Map arguments]) { |
| 53 log(new Message(errorCode, arguments, false)); | 53 log(new Message(MessageTemplate.TEMPLATES[errorCode], arguments, false)); |
| 54 } | 54 } |
| 55 | 55 |
| 56 void reportInfo(Spannable node, MessageKind errorCode, [Map arguments]) { | 56 void reportInfo(Spannable node, MessageKind errorCode, [Map arguments]) { |
| 57 log(new Message(errorCode, arguments, false)); | 57 log(new Message(MessageTemplate.TEMPLATES[errorCode], arguments, false)); |
| 58 } | 58 } |
| 59 | 59 |
| 60 void reportHint(Spannable node, MessageKind errorCode, [Map arguments]) { | 60 void reportHint(Spannable node, MessageKind errorCode, [Map arguments]) { |
| 61 log(new Message(errorCode, arguments, false)); | 61 log(new Message(MessageTemplate.TEMPLATES[errorCode], arguments, false)); |
| 62 } | 62 } |
| 63 | 63 |
| 64 withCurrentElement(Element element, f()) => f(); | 64 withCurrentElement(Element element, f()) => f(); |
| 65 } | 65 } |
| 66 | 66 |
| 67 Token scan(String text) => | 67 Token scan(String text) => |
| 68 new StringScanner.fromString(text) | 68 new StringScanner.fromString(text) |
| 69 .tokenize(); | 69 .tokenize(); |
| 70 | 70 |
| 71 Node parseBodyCode(String text, Function parseMethod, | 71 Node parseBodyCode(String text, Function parseMethod, |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 ElementListener listener = new ElementListener(compiler, unit, () => id++); | 123 ElementListener listener = new ElementListener(compiler, unit, () => id++); |
| 124 PartialParser parser = new PartialParser(listener); | 124 PartialParser parser = new PartialParser(listener); |
| 125 compiler.withCurrentElement(unit, () => parser.parseUnit(tokens)); | 125 compiler.withCurrentElement(unit, () => parser.parseUnit(tokens)); |
| 126 return unit.localMembers; | 126 return unit.localMembers; |
| 127 } | 127 } |
| 128 | 128 |
| 129 NodeList fullParseUnit(String source, {DiagnosticListener diagnosticHandler}) { | 129 NodeList fullParseUnit(String source, {DiagnosticListener diagnosticHandler}) { |
| 130 return parseBodyCode(source, (parser, tokens) => parser.parseUnit(tokens), | 130 return parseBodyCode(source, (parser, tokens) => parser.parseUnit(tokens), |
| 131 diagnosticHandler: diagnosticHandler); | 131 diagnosticHandler: diagnosticHandler); |
| 132 } | 132 } |
| OLD | NEW |