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

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

Issue 18323004: Add lookupInScope to DeclarationMirror. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 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/compiler/implementation/mirrors/mirrors_util.dart
diff --git a/sdk/lib/_internal/compiler/implementation/mirrors/mirrors_util.dart b/sdk/lib/_internal/compiler/implementation/mirrors/mirrors_util.dart
index ae01ea08c5c2c595968bf5568fc61aab40ba4a80..08c243e199632bfc7795b8560da7da090b62c372 100644
--- a/sdk/lib/_internal/compiler/implementation/mirrors/mirrors_util.dart
+++ b/sdk/lib/_internal/compiler/implementation/mirrors/mirrors_util.dart
@@ -217,3 +217,25 @@ String stripComment(String comment) {
}
throw new ArgumentError('Invalid comment $comment');
}
+
+/**
+ * Looks up [name] in the scope [declaration].
+ *
+ * For methods and constructors, the scope includes the parameters.
+ *
+ * If [name] is of the form [: a.b.c :], [:a:] is looked up in the scope of
+ * [declaration], [:b:] is looked up in the scope of [:a:], and finally [:c:] is
+ * looked up in the scope of [:b:].
+ */
+DeclarationMirror lookupQualifiedInScope(DeclarationMirror declaration,
+ String name) {
+ // TODO(johnniwinther): Support lookup of constructors using the [:new Foo:]
+ // syntax.
+ for (String part in name.split('.')) {
+ if (declaration == null) {
Andrei Mouravski 2013/07/01 17:46:26 Nit: One line this?
Johnni Winther 2013/07/03 05:47:57 Done.
+ return null;
+ }
+ declaration = declaration.lookupInScope(part);
+ }
+ return declaration;
+}

Powered by Google App Engine
This is Rietveld 408576698