Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 } | |
| OLD | NEW |