OLD | NEW |
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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:compiler/src/common.dart'; | 5 import 'package:compiler/src/common.dart'; |
6 import 'package:compiler/src/common_elements.dart'; | 6 import 'package:compiler/src/common_elements.dart'; |
7 import 'package:compiler/src/compiler.dart'; | 7 import 'package:compiler/src/compiler.dart'; |
8 import 'package:compiler/src/elements/elements.dart'; | 8 import 'package:compiler/src/elements/elements.dart'; |
9 import 'package:compiler/src/elements/entities.dart'; | 9 import 'package:compiler/src/elements/entities.dart'; |
10 import 'package:compiler/src/resolution/tree_elements.dart'; | 10 import 'package:compiler/src/resolution/tree_elements.dart'; |
11 import 'package:compiler/src/tree/nodes.dart'; | 11 import 'package:compiler/src/tree/nodes.dart'; |
12 import 'package:compiler/src/types/types.dart'; | 12 import 'package:compiler/src/types/types.dart'; |
13 import 'package:expect/expect.dart'; | 13 import 'package:expect/expect.dart'; |
14 | 14 |
15 import '../annotated_code_helper.dart'; | 15 import '../annotated_code_helper.dart'; |
16 import '../memory_compiler.dart'; | 16 import '../memory_compiler.dart'; |
17 import 'enumerator.dart'; | 17 import 'enumerator.dart'; |
18 | 18 |
19 typedef void CheckMemberFunction( | 19 typedef void CheckMemberFunction( |
20 Compiler compiler, Map<Id, String> expectedMap, MemberElement member); | 20 Compiler compiler, Map<Id, String> expectedMap, MemberElement member); |
21 | 21 |
22 /// Compiles the [annotatedCode] with the provided [options] and calls | 22 /// Compiles the [annotatedCode] with the provided [options] and calls |
23 /// [checkMember] for each member in the code providing the map from [Id] to | 23 /// [checkMember] for each member in the code providing the map from [Id] to |
24 /// annotation. Any [Id] left in the map will be reported as missing. | 24 /// annotation. Any [Id] left in the map will be reported as missing. |
25 checkCode(String annotatedCode, CheckMemberFunction checkMember, | 25 checkCode(String annotatedCode, CheckMemberFunction checkMember, |
26 {List<String> options: const <String>[]}) async { | 26 {List<String> options: const <String>[]}) async { |
27 AnnotatedCode code = new AnnotatedCode.fromText(annotatedCode, '/*', '*/'); | 27 AnnotatedCode code = |
| 28 new AnnotatedCode.fromText(annotatedCode, commentStart, commentEnd); |
28 Map<Id, String> expectedMap = computeExpectedMap(code); | 29 Map<Id, String> expectedMap = computeExpectedMap(code); |
29 Compiler compiler = compilerFor( | 30 Compiler compiler = compilerFor( |
30 memorySourceFiles: {'main.dart': code.sourceCode}, options: options); | 31 memorySourceFiles: {'main.dart': code.sourceCode}, options: options); |
31 compiler.stopAfterTypeInference = true; | 32 compiler.stopAfterTypeInference = true; |
32 Uri mainUri = Uri.parse('memory:main.dart'); | 33 Uri mainUri = Uri.parse('memory:main.dart'); |
33 await compiler.run(mainUri); | 34 await compiler.run(mainUri); |
34 LibraryElement mainApp = compiler.mainApp; | 35 LibraryElement mainApp = compiler.mainApp; |
35 mainApp.forEachLocalMember((dynamic member) { | 36 mainApp.forEachLocalMember((dynamic member) { |
36 if (member.isClass) { | 37 if (member.isClass) { |
37 member.forEachLocalMember((member) { | 38 member.forEachLocalMember((member) { |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 visitSend(Send node) { | 174 visitSend(Send node) { |
174 checkSend(node); | 175 checkSend(node); |
175 visitNode(node); | 176 visitNode(node); |
176 } | 177 } |
177 | 178 |
178 visitSendSet(SendSet node) { | 179 visitSendSet(SendSet node) { |
179 checkSend(node); | 180 checkSend(node); |
180 visitNode(node); | 181 visitNode(node); |
181 } | 182 } |
182 } | 183 } |
OLD | NEW |