Chromium Code Reviews| Index: reflectable/lib/reflectable.dart |
| diff --git a/reflectable/lib/reflectable.dart b/reflectable/lib/reflectable.dart |
| index 5b8281293a5b07f386590ce1709bdea29817a48a..e1f8f9f4b0dfad5ce5f1fd97c529586f024f1d98 100644 |
| --- a/reflectable/lib/reflectable.dart |
| +++ b/reflectable/lib/reflectable.dart |
| @@ -90,7 +90,7 @@ abstract class ReflectableInterface { |
| /// which means that the behavior of the instance can be expressed by |
| /// generating code in the class. Generalizations of this setup may |
| /// be supported in the future if compelling use cases come up. |
| -class Reflectable extends implementation.ReflectableImpl |
| +abstract class Reflectable extends implementation.ReflectableImpl |
| implements ReflectableInterface { |
| // Intended to near-uniquely identify this class in target programs. |
| static const thisClassName = reflectable_class_constants.name; |
| @@ -108,6 +108,19 @@ class Reflectable extends implementation.ReflectableImpl |
| const Reflectable.fromList(List<ReflectCapability> capabilities) |
| : super.fromList(capabilities); |
| + |
| + |
| + /// Returns the canonicalized instance of the given reflector [type], if |
| + /// there is such an instance which is being used as a reflector. If |
|
sigurdm
2015/10/09 10:47:20
Add new paragraph after first sentence.
eernst
2015/10/09 11:24:14
Done.
|
| + /// [type] is not a subclass of [Reflectable], or if it is such a class |
| + /// but no entities are covered (that is, it is unused, so we don't have |
| + /// any reflection data for it) then [null] is returned. |
| + static Reflectable getInstance(Type type) { |
| + for (Reflectable reflector in implementation.reflectors) { |
| + if (reflector.runtimeType == type) return reflector; |
| + } |
| + return null; |
| + } |
| } |
| /// Returns true if the transformed version is running, false otherwise. |