| 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/implementation/elements/elements.dart"; | 9 import "package:compiler/implementation/elements/elements.dart"; |
| 10 import "package:compiler/implementation/tree/tree.dart"; | 10 import "package:compiler/implementation/tree/tree.dart"; |
| 11 import "package:compiler/implementation/scanner/scannerlib.dart"; | 11 import "package:compiler/implementation/scanner/scannerlib.dart"; |
| 12 import "package:compiler/implementation/source_file.dart"; | 12 import "package:compiler/implementation/source_file.dart"; |
| 13 import "package:compiler/implementation/util/util.dart"; | 13 import "package:compiler/implementation/util/util.dart"; |
| 14 | 14 |
| 15 import "package:compiler/implementation/elements/modelx.dart" | 15 import "package:compiler/implementation/elements/modelx.dart" |
| 16 show CompilationUnitElementX, | 16 show CompilationUnitElementX, ElementX, LibraryElementX; |
| 17 LibraryElementX; | |
| 18 | 17 |
| 19 import "package:compiler/implementation/dart2jslib.dart"; | 18 import "package:compiler/implementation/dart2jslib.dart"; |
| 20 | 19 |
| 21 export "package:compiler/implementation/dart2jslib.dart" | 20 export "package:compiler/implementation/dart2jslib.dart" |
| 22 show DiagnosticListener; | 21 show DiagnosticListener; |
| 23 // TODO(ahe): We should have token library to export instead. | 22 // TODO(ahe): We should have token library to export instead. |
| 24 export "package:compiler/implementation/scanner/scannerlib.dart"; | 23 export "package:compiler/implementation/scanner/scannerlib.dart"; |
| 25 | 24 |
| 26 class LoggerCanceler implements DiagnosticListener { | 25 class LoggerCanceler implements DiagnosticListener { |
| 27 void cancel(String reason, {node, token, instruction, element}) { | 26 void cancel(String reason, {node, token, instruction, element}) { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 Node node = listener.popNode(); | 86 Node node = listener.popNode(); |
| 88 Expect.isNotNull(node); | 87 Expect.isNotNull(node); |
| 89 Expect.isTrue(listener.nodes.isEmpty, 'Not empty: ${listener.nodes}'); | 88 Expect.isTrue(listener.nodes.isEmpty, 'Not empty: ${listener.nodes}'); |
| 90 return node; | 89 return node; |
| 91 } | 90 } |
| 92 | 91 |
| 93 Node parseStatement(String text) => | 92 Node parseStatement(String text) => |
| 94 parseBodyCode(text, (parser, tokens) => parser.parseStatement(tokens)); | 93 parseBodyCode(text, (parser, tokens) => parser.parseStatement(tokens)); |
| 95 | 94 |
| 96 Node parseFunction(String text, Compiler compiler) { | 95 Node parseFunction(String text, Compiler compiler) { |
| 97 Element element = parseUnit(text, compiler, compiler.mainApp).head; | 96 ElementX element = parseUnit(text, compiler, compiler.mainApp).head; |
| 98 Expect.isNotNull(element); | 97 Expect.isNotNull(element); |
| 99 Expect.equals(ElementKind.FUNCTION, element.kind); | 98 Expect.equals(ElementKind.FUNCTION, element.kind); |
| 100 return element.parseNode(compiler); | 99 return element.parseNode(compiler); |
| 101 } | 100 } |
| 102 | 101 |
| 103 Node parseMember(String text, {DiagnosticListener diagnosticHandler}) { | 102 Node parseMember(String text, {DiagnosticListener diagnosticHandler}) { |
| 104 return parseBodyCode(text, (parser, tokens) => parser.parseMember(tokens), | 103 return parseBodyCode(text, (parser, tokens) => parser.parseMember(tokens), |
| 105 diagnosticHandler: diagnosticHandler); | 104 diagnosticHandler: diagnosticHandler); |
| 106 } | 105 } |
| 107 | 106 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 126 ElementListener listener = new ElementListener(compiler, unit, () => id++); | 125 ElementListener listener = new ElementListener(compiler, unit, () => id++); |
| 127 PartialParser parser = new PartialParser(listener); | 126 PartialParser parser = new PartialParser(listener); |
| 128 compiler.withCurrentElement(unit, () => parser.parseUnit(tokens)); | 127 compiler.withCurrentElement(unit, () => parser.parseUnit(tokens)); |
| 129 return unit.localMembers; | 128 return unit.localMembers; |
| 130 } | 129 } |
| 131 | 130 |
| 132 NodeList fullParseUnit(String source, {DiagnosticListener diagnosticHandler}) { | 131 NodeList fullParseUnit(String source, {DiagnosticListener diagnosticHandler}) { |
| 133 return parseBodyCode(source, (parser, tokens) => parser.parseUnit(tokens), | 132 return parseBodyCode(source, (parser, tokens) => parser.parseUnit(tokens), |
| 134 diagnosticHandler: diagnosticHandler); | 133 diagnosticHandler: diagnosticHandler); |
| 135 } | 134 } |
| OLD | NEW |