OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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/id_generator.dart'; |
10 import "package:compiler/src/tree/tree.dart"; | 11 import "package:compiler/src/tree/tree.dart"; |
11 import "package:compiler/src/parser/element_listener.dart"; | 12 import "package:compiler/src/parser/element_listener.dart"; |
12 import "package:compiler/src/parser/node_listener.dart"; | 13 import "package:compiler/src/parser/node_listener.dart"; |
13 import "package:compiler/src/parser/parser.dart"; | 14 import "package:compiler/src/parser/parser.dart"; |
14 import "package:compiler/src/parser/partial_parser.dart"; | 15 import "package:compiler/src/parser/partial_parser.dart"; |
15 import "package:compiler/src/scanner/string_scanner.dart"; | 16 import "package:compiler/src/scanner/string_scanner.dart"; |
16 import "package:compiler/src/tokens/token.dart"; | 17 import "package:compiler/src/tokens/token.dart"; |
17 import "package:compiler/src/tokens/token_constants.dart"; | 18 import "package:compiler/src/tokens/token_constants.dart"; |
18 import "package:compiler/src/io/source_file.dart"; | 19 import "package:compiler/src/io/source_file.dart"; |
19 import "package:compiler/src/util/util.dart"; | 20 import "package:compiler/src/util/util.dart"; |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 Link<Element> parseUnit(String text, Compiler compiler, | 144 Link<Element> parseUnit(String text, Compiler compiler, |
144 LibraryElement library, | 145 LibraryElement library, |
145 [void registerSource(Uri uri, String source)]) { | 146 [void registerSource(Uri uri, String source)]) { |
146 Token tokens = scan(text); | 147 Token tokens = scan(text); |
147 Uri uri = new Uri(scheme: "source", path: '${++sourceCounter}'); | 148 Uri uri = new Uri(scheme: "source", path: '${++sourceCounter}'); |
148 if (registerSource != null) { | 149 if (registerSource != null) { |
149 registerSource(uri, text); | 150 registerSource(uri, text); |
150 } | 151 } |
151 var script = new Script(uri, uri, new MockFile(text)); | 152 var script = new Script(uri, uri, new MockFile(text)); |
152 var unit = new CompilationUnitElementX(script, library); | 153 var unit = new CompilationUnitElementX(script, library); |
153 int id = 0; | |
154 DiagnosticReporter reporter = compiler.reporter; | 154 DiagnosticReporter reporter = compiler.reporter; |
155 ElementListener listener = new ElementListener( | 155 ElementListener listener = new ElementListener( |
156 compiler.parsing.getScannerOptionsFor(library), | 156 compiler.parsing.getScannerOptionsFor(library), |
157 reporter, unit, () => id++); | 157 reporter, unit, new IdGenerator()); |
158 PartialParser parser = new PartialParser(listener, new MockParserOptions()); | 158 PartialParser parser = new PartialParser(listener, new MockParserOptions()); |
159 reporter.withCurrentElement(unit, () => parser.parseUnit(tokens)); | 159 reporter.withCurrentElement(unit, () => parser.parseUnit(tokens)); |
160 return unit.localMembers; | 160 return unit.localMembers; |
161 } | 161 } |
162 | 162 |
163 NodeList fullParseUnit(String source, {DiagnosticReporter reporter}) { | 163 NodeList fullParseUnit(String source, {DiagnosticReporter reporter}) { |
164 return parseBodyCode( | 164 return parseBodyCode( |
165 source, | 165 source, |
166 (parser, tokens) => parser.parseUnit(tokens), | 166 (parser, tokens) => parser.parseUnit(tokens), |
167 reporter: reporter); | 167 reporter: reporter); |
168 } | 168 } |
OLD | NEW |