Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1109)

Unified Diff: sdk/lib/_internal/compiler/implementation/mirrors/dart2js_mirrors.dart

Issue 268583002: Access parameter data in Annotations, as well as fixed export visibility (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/docgen/test/multi_library_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/compiler/implementation/mirrors/dart2js_mirrors.dart
diff --git a/sdk/lib/_internal/compiler/implementation/mirrors/dart2js_mirrors.dart b/sdk/lib/_internal/compiler/implementation/mirrors/dart2js_mirrors.dart
index 5ae18d7c68b2cd7aff3f4e5b3cbc3287757f41f9..ad90a7a8cf30ae2b2eed919f23428b0f41853fe8 100644
--- a/sdk/lib/_internal/compiler/implementation/mirrors/dart2js_mirrors.dart
+++ b/sdk/lib/_internal/compiler/implementation/mirrors/dart2js_mirrors.dart
@@ -458,6 +458,19 @@ class Dart2JsCompilationUnitMirror extends Dart2JsMirror with ContainerMixin {
Uri get uri => _element.script.resourceUri;
}
+class ResolvedNode {
+ final node;
+ 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.
@@ -470,4 +483,33 @@ 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(
+ (MetadataAnnotation 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);
+ }
}
« no previous file with comments | « pkg/docgen/test/multi_library_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698