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

Unified Diff: sdk/lib/_internal/lib/js_mirrors.dart

Issue 36023003: Add LibraryMirror.declarations and ClassMirror.declarations to the API and both implementations. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: typevars are not static Created 7 years, 2 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
Index: sdk/lib/_internal/lib/js_mirrors.dart
diff --git a/sdk/lib/_internal/lib/js_mirrors.dart b/sdk/lib/_internal/lib/js_mirrors.dart
index e5d73b04329280aa3c0c20c4520ac5cfe7852b44..c3df3425b2e599c7eaad6f8b7884f3c55f17dae4 100644
--- a/sdk/lib/_internal/lib/js_mirrors.dart
+++ b/sdk/lib/_internal/lib/js_mirrors.dart
@@ -253,6 +253,7 @@ class JsLibraryMirror extends JsDeclarationMirror with JsObjectMirror
UnmodifiableMapView<Symbol, MethodMirror> _cachedSetters;
UnmodifiableMapView<Symbol, VariableMirror> _cachedVariables;
UnmodifiableMapView<Symbol, Mirror> _cachedMembers;
+ UnmodifiableMapView<Symbol, DeclarationMirror> _cachedDeclarations;
UnmodifiableListView<InstanceMirror> _cachedMetadata;
JsLibraryMirror(Symbol simpleName,
@@ -430,6 +431,17 @@ class JsLibraryMirror extends JsDeclarationMirror with JsObjectMirror
return _cachedMembers = new UnmodifiableMapView<Symbol, Mirror>(result);
}
+ Map<Symbol, DeclarationMirror> get declarations {
+ if (_cachedDeclarations != null) return _cachedDeclarations;
+ var result = new Map<Symbol, DeclarationMirror>();
+ addToResult(Symbol key, Mirror value) {
+ result[key] = value;
+ }
+ members.forEach(addToResult);
+ return _cachedDeclarations =
+ new UnmodifiableMapView<Symbol, DeclarationMirror>(result);
+ }
+
List<InstanceMirror> get metadata {
if (_cachedMetadata != null) return _cachedMetadata;
preserveMetadata();
@@ -986,6 +998,7 @@ class JsClassMirror extends JsTypeMirror with JsObjectMirror
UnmodifiableMapView<Symbol, MethodMirror> _cachedSetters;
UnmodifiableMapView<Symbol, VariableMirror> _cachedVariables;
UnmodifiableMapView<Symbol, Mirror> _cachedMembers;
+ UnmodifiableMapView<Symbol, DeclarationMirror> _cachedDeclarations;
UnmodifiableListView<InstanceMirror> _cachedMetadata;
UnmodifiableListView<ClassMirror> _cachedSuperinterfaces;
UnmodifiableListView<TypeVariableMirror> _cachedTypeVariables;
@@ -1176,6 +1189,19 @@ class JsClassMirror extends JsTypeMirror with JsObjectMirror
return _cachedMembers = new UnmodifiableMapView<Symbol, Mirror>(result);
}
+ Map<Symbol, DeclarationMirror> get declarations {
+ if (_cachedDeclarations != null) return _cachedDeclarations;
+ var result = new Map<Symbol, DeclarationMirror>();
+ addToResult(Symbol key, Mirror value) {
+ result[key] = value;
+ }
+ members.forEach(addToResult);
+ constructors.forEach(addToResult);
+ typeVariables.forEach((tv) => result[tv.simpleName] = tv);
+ return _cachedDeclarations =
+ new UnmodifiableMapView<Symbol, DeclarationMirror>(result);
+ }
+
InstanceMirror setField(Symbol fieldName, Object arg) {
JsVariableMirror mirror = variables[fieldName];
if (mirror != null && mirror.isStatic && !mirror.isFinal) {

Powered by Google App Engine
This is Rietveld 408576698