OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 testing.abstract_context; | 5 library testing.abstract_context; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
9 import 'package:analyzer/dart/ast/ast.dart'; | 9 import 'package:analyzer/dart/ast/ast.dart'; |
10 import 'package:analyzer/dart/element/element.dart'; | 10 import 'package:analyzer/dart/element/element.dart'; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 return _driver; | 69 return _driver; |
70 } | 70 } |
71 throw new StateError('Should be used with the new analysis driver.'); | 71 throw new StateError('Should be used with the new analysis driver.'); |
72 } | 72 } |
73 | 73 |
74 /** | 74 /** |
75 * Return `true` if the new analysis driver should be used by these tests. | 75 * Return `true` if the new analysis driver should be used by these tests. |
76 */ | 76 */ |
77 bool get enableNewAnalysisDriver => false; | 77 bool get enableNewAnalysisDriver => false; |
78 | 78 |
| 79 Source addMetaPackageSource() => addPackageSource( |
| 80 'meta', |
| 81 'meta.dart', |
| 82 r''' |
| 83 library meta; |
| 84 |
| 85 const Required required = const Required(); |
| 86 |
| 87 class Required { |
| 88 final String reason; |
| 89 const Required([this.reason]); |
| 90 } |
| 91 '''); |
| 92 |
79 Source addPackageSource(String packageName, String filePath, String content) { | 93 Source addPackageSource(String packageName, String filePath, String content) { |
80 packageMap[packageName] = [(newFolder('/pubcache/$packageName'))]; | 94 packageMap[packageName] = [(newFolder('/pubcache/$packageName'))]; |
81 File file = newFile('/pubcache/$packageName/$filePath', content); | 95 File file = newFile('/pubcache/$packageName/$filePath', content); |
82 return file.createSource(); | 96 return file.createSource(); |
83 } | 97 } |
84 | 98 |
85 Source addSource(String path, String content, [Uri uri]) { | 99 Source addSource(String path, String content, [Uri uri]) { |
86 File file = newFile(path, content); | 100 File file = newFile(path, content); |
87 if (enableNewAnalysisDriver) { | 101 if (enableNewAnalysisDriver) { |
88 driver.addFile(path); | 102 driver.addFile(path); |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 * [engine.GeneralizingElementVisitor]. | 216 * [engine.GeneralizingElementVisitor]. |
203 */ | 217 */ |
204 class _ElementVisitorFunctionWrapper extends GeneralizingElementVisitor { | 218 class _ElementVisitorFunctionWrapper extends GeneralizingElementVisitor { |
205 final _ElementVisitorFunction function; | 219 final _ElementVisitorFunction function; |
206 _ElementVisitorFunctionWrapper(this.function); | 220 _ElementVisitorFunctionWrapper(this.function); |
207 visitElement(Element element) { | 221 visitElement(Element element) { |
208 function(element); | 222 function(element); |
209 super.visitElement(element); | 223 super.visitElement(element); |
210 } | 224 } |
211 } | 225 } |
OLD | NEW |