Chromium Code Reviews| Index: dart/sdk/lib/_internal/compiler/implementation/mirrors/dart2js_mirrors.dart |
| diff --git a/dart/sdk/lib/_internal/compiler/implementation/mirrors/dart2js_mirrors.dart b/dart/sdk/lib/_internal/compiler/implementation/mirrors/dart2js_mirrors.dart |
| index a4f88c2f31249cf227cd1a0d8a895d12189de20e..8ab65c65916f2578211332fe6decb7d2855a84ce 100644 |
| --- a/dart/sdk/lib/_internal/compiler/implementation/mirrors/dart2js_mirrors.dart |
| +++ b/dart/sdk/lib/_internal/compiler/implementation/mirrors/dart2js_mirrors.dart |
| @@ -452,6 +452,19 @@ class Dart2JsCompilationUnitMirror extends Dart2JsMirror |
| Uri get uri => _element.script.resourceUri; |
| } |
| +class ResolvedNode { |
| + final node; |
|
kevmoo
2014/04/25 12:58:11
Types here? Is nice...
ahe
2014/04/25 13:06:09
I didn't want to add types as I didn't want to add
|
| + final _elements; |
| + final _mirrorSystem; |
| + ResolvedNode(this.node, this._elements, this._mirrorSystem); |
| + |
| + Mirror resolvedMirror(node) { |
| + var element = _elements[node]; |
| + if (element == null) return null; |
| + return _convertElementToDeclarationMirror(_mirrorSystem, element); |
| + } |
| +} |
| + |
| /** |
| * Transitional class that allows access to features that have not yet |
| * made it to the mirror API. |
| @@ -464,4 +477,32 @@ class BackDoor { |
| return library._element.compilationUnits.toList().map( |
| (cu) => new Dart2JsCompilationUnitMirror(cu, library)).toList(); |
| } |
| + |
| + static Iterable metadataSyntaxOf(Dart2JsElementMirror declaration) { |
| + Compiler compiler = declaration.mirrorSystem.compiler; |
| + return declaration._element.metadata.toList().map((metadata) { |
| + var node = metadata.parseNode(compiler); |
| + Element annotatedElement = metadata.annotatedElement; |
| + var context = annotatedElement.enclosingElement; |
| + if (context == null) { |
| + context = annotatedElement; |
| + } |
| + return new ResolvedNode( |
| + node, context.treeElements, declaration.mirrorSystem); |
| + }); |
| + } |
| + |
| + static ResolvedNode initializerSyntaxOf(Dart2JsFieldMirror variable) { |
| + var node = variable._variable.initializer; |
| + if (node == null) return null; |
| + return new ResolvedNode( |
| + node, variable._variable.treeElements, variable.mirrorSystem); |
| + } |
| + |
| + static ResolvedNode defaultValueSyntaxOf(Dart2JsParameterMirror parameter) { |
| + if (!parameter.hasDefaultValue) return null; |
| + var node = parameter._element.initializer; |
| + return new ResolvedNode( |
| + node, parameter.owner._element.treeElements, parameter.mirrorSystem); |
| + } |
| } |