OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 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. |
| 4 |
| 5 /// Holds some common functions that manipulate mirror objects. |
| 6 library checked_mirrors.src.utils; |
| 7 |
| 8 import 'dart:mirrors'; |
| 9 |
| 10 /// Helper to retrieve the library uri where [object] is defined. |
| 11 Uri getLibraryUriOf(Mirror object) { |
| 12 var declaration = getDeclarationOf(object); |
| 13 if (declaration == null) return null; |
| 14 if (declaration is LibraryMirror) return declaration.uri; |
| 15 return getLibraryUriOf(declaration.owner); |
| 16 } |
| 17 |
| 18 /// Helper to retrieve the declaration of [object]. |
| 19 DeclarationMirror getDeclarationOf(Mirror object) { |
| 20 if (object is DeclarationMirror) return object; |
| 21 if (object is InstanceMirror) return object.type; |
| 22 return null; |
| 23 } |
OLD | NEW |