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

Side by Side 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, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 mirrors_util; 5 library mirrors_util;
6 6
7 import 'dart:collection' show Queue, IterableBase; 7 import 'dart:collection' show Queue, IterableBase;
8 8
9 // TODO(rnystrom): Use "package:" URL (#4968). 9 // TODO(rnystrom): Use "package:" URL (#4968).
10 import 'mirrors.dart'; 10 import 'mirrors.dart';
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 // * Foo 210 // * Foo
211 // */ 211 // */
212 // as "\nFoo\n" and not as "\nFoo\n ". 212 // as "\nFoo\n" and not as "\nFoo\n ".
213 sb.write(line); 213 sb.write(line);
214 } 214 }
215 } 215 }
216 return sb.toString(); 216 return sb.toString();
217 } 217 }
218 throw new ArgumentError('Invalid comment $comment'); 218 throw new ArgumentError('Invalid comment $comment');
219 } 219 }
220
221 /**
222 * Looks up [name] in the scope [declaration].
223 *
224 * For methods and constructors, the scope includes the parameters.
225 *
226 * If [name] is of the form [: a.b.c :], [:a:] is looked up in the scope of
227 * [declaration], [:b:] is looked up in the scope of [:a:], and finally [:c:] is
228 * looked up in the scope of [:b:].
229 */
230 DeclarationMirror lookupQualifiedInScope(DeclarationMirror declaration,
231 String name) {
232 // TODO(johnniwinther): Support lookup of constructors using the [:new Foo:]
233 // syntax.
234 for (String part in name.split('.')) {
235 if (declaration == null) {
Andrei Mouravski 2013/07/01 17:46:26 Nit: One line this?
Johnni Winther 2013/07/03 05:47:57 Done.
236 return null;
237 }
238 declaration = declaration.lookupInScope(part);
239 }
240 return declaration;
241 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698