| 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 library polymer_expressions.src.mirrors; | |
| 6 | |
| 7 import 'package:observe/observe.dart' show Reflectable, ObservableProperty; | |
| 8 | |
| 9 @MirrorsUsed(metaTargets: const [Reflectable, ObservableProperty], | |
| 10 override: 'polymer_expressions.src.mirrors') | |
| 11 import 'dart:mirrors'; | |
| 12 | |
| 13 /** | |
| 14 * Walks up the class hierarchy to find a method declaration with the given | |
| 15 * [name]. | |
| 16 * | |
| 17 * Note that it's not possible to tell if there's an implementation via | |
| 18 * noSuchMethod(). | |
| 19 */ | |
| 20 Mirror getMemberMirror(ClassMirror classMirror, Symbol name) { | |
| 21 if (classMirror.declarations.containsKey(name)) { | |
| 22 return classMirror.declarations[name]; | |
| 23 } | |
| 24 if (hasSuperclass(classMirror)) { | |
| 25 var mirror = getMemberMirror(classMirror.superclass, name); | |
| 26 if (mirror != null) { | |
| 27 return mirror; | |
| 28 } | |
| 29 } | |
| 30 for (ClassMirror supe in classMirror.superinterfaces) { | |
| 31 var mirror = getMemberMirror(supe, name); | |
| 32 if (mirror != null) { | |
| 33 return mirror; | |
| 34 } | |
| 35 } | |
| 36 return null; | |
| 37 } | |
| 38 | |
| 39 /** | |
| 40 * Work-around for http://dartbug.com/5794 | |
| 41 */ | |
| 42 bool hasSuperclass(ClassMirror classMirror) { | |
| 43 var superclass = classMirror.superclass; | |
| 44 return (superclass != null) && | |
| 45 (superclass.qualifiedName != #dart.core.Object); | |
| 46 } | |
| OLD | NEW |