| 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 /** | 5 /** |
| 6 * Provides some additional convenience methods on top of the basic mirrors | 6 * Provides some additional convenience methods on top of the basic mirrors |
| 7 */ | 7 */ |
| 8 library mirrors_helpers; | 8 library mirrors_helpers; |
| 9 | 9 |
| 10 // Import and re-export mirrors here to minimize both dependence on mirrors | 10 // Import and re-export mirrors here to minimize both dependence on mirrors |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 * Return a list of all the public getters of a class which have corresponding | 75 * Return a list of all the public getters of a class which have corresponding |
| 76 * setters. | 76 * setters. |
| 77 */ | 77 */ |
| 78 Iterable<MethodMirror> publicGettersWithMatchingSetters(ClassMirror mirror) { | 78 Iterable<MethodMirror> publicGettersWithMatchingSetters(ClassMirror mirror) { |
| 79 var setters = mirror.setters; | 79 var setters = mirror.setters; |
| 80 return publicGetters(mirror).where((each) => | 80 return publicGetters(mirror).where((each) => |
| 81 setters["${each.simpleName}="] != null); | 81 setters["${each.simpleName}="] != null); |
| 82 } | 82 } |
| 83 | 83 |
| 84 /** | 84 /** |
| 85 * A particularly bad case of polyfill, because we cannot yet use type names | 85 * Given either an instance or a type, returns the type. Instances of Type |
| 86 * as literals, so we have to be passed an instance and then extract a | 86 * will be treated as types. Passing in an instance is really just backward |
| 87 * ClassMirror from that. Given a horrible name as an extra reminder to fix it. | 87 * compatibility. |
| 88 */ | 88 */ |
| 89 ClassMirror turnInstanceIntoSomethingWeCanUse(x) => reflect(x).type; | 89 ClassMirror turnInstanceIntoSomethingWeCanUse(x) { |
| 90 if (x is Type) return reflectClass(x); |
| 91 return reflect(x).type; |
| 92 } |
| OLD | NEW |