Chromium Code Reviews| Index: reflectable/lib/src/reflectable_transformer_based.dart |
| diff --git a/reflectable/lib/src/reflectable_transformer_based.dart b/reflectable/lib/src/reflectable_transformer_based.dart |
| index a7b3ef86eeff45fc55948c8fee52da0115c826ab..d58a584bdcf71fa92ab9e9fe33702e8c51e3434c 100644 |
| --- a/reflectable/lib/src/reflectable_transformer_based.dart |
| +++ b/reflectable/lib/src/reflectable_transformer_based.dart |
| @@ -109,7 +109,15 @@ class ReflectorData { |
| _typeToClassMirrorCache = new Map.fromIterables(types, classMirrors); |
| } |
| } |
| - return _typeToClassMirrorCache[type]; |
| + ClassMirror result = _typeToClassMirrorCache[type]; |
| + if (result == null && "$type".startsWith("_")) { |
|
sigurdm
2015/10/15 12:30:58
Abstract startsWith("_") to isPrivateName()
eernst
2015/10/15 13:46:11
This section deleted: We do not support reflecting
|
| + for (Type typeKey in _typeToClassMirrorCache.keys) { |
| + if (typeKey is FakeType && typeKey.correspondsTo(type)) { |
| + return _typeToClassMirrorCache[typeKey]; |
| + } |
| + } |
| + } |
| + return result; |
| } |
| } |
| @@ -499,14 +507,8 @@ class ClassMirrorImpl extends _DataCaching implements ClassMirror { |
| } |
| class LibraryMirrorImpl extends _DataCaching implements LibraryMirror { |
| - LibraryMirrorImpl( |
| - this.simpleName, |
| - this.uri, |
| - this._reflector, |
| - this._declarationIndices, |
| - this.getters, |
| - this.setters, |
| - this._metadata); |
| + LibraryMirrorImpl(this.simpleName, this.uri, this._reflector, |
| + this._declarationIndices, this.getters, this.setters, this._metadata); |
| final ReflectableImpl _reflector; |
| @@ -551,6 +553,11 @@ class LibraryMirrorImpl extends _DataCaching implements LibraryMirror { |
| _data.memberMirrors[declarationIndex]; |
| result[declarationMirror.simpleName] = declarationMirror; |
| } |
| + _data.classMirrors.forEach((ClassMirror classMirror) { |
| + if (classMirror.owner == this) { |
| + result[classMirror.simpleName] = classMirror; |
| + } |
| + }); |
| _declarations = |
| new UnmodifiableMapView<String, DeclarationMirror>(result); |
| } |
| @@ -612,8 +619,15 @@ class LibraryMirrorImpl extends _DataCaching implements LibraryMirror { |
| @override |
| String get qualifiedName => simpleName; |
| - bool operator ==(other) => _unsupported(); |
| - int get hashCode => _unsupported(); |
| + bool operator ==(other) { |
| + return other is LibraryMirrorImpl && |
| + other.uri == uri && |
| + other._reflector == _reflector && |
| + other._declarationIndices == _declarationIndices; |
| + } |
| + |
| + int get hashCode => |
| + uri.hashCode ^ _reflector.hashCode ^ _declarationIndices.hashCode; |
| // TODO(sigurdm) implement: Need to implement this. Probably only when a given |
| // capability is enabled. |
| @@ -1263,4 +1277,13 @@ class FakeType implements Type { |
| final String description; |
| String toString() => "Type($description)"; |
| + |
| + /// Make a best effort attempt to recognize that this fake type represents |
| + /// the given [type]. Only private non-mixin-application types are recognized, |
| + bool correspondsTo(Type type) { |
|
sigurdm
2015/10/15 12:30:58
I think this support for reflecting on instances o
eernst
2015/10/15 13:46:11
Deleted, too.
|
| + if (description.contains(" with ")) return false; |
| + String typeName = type.toString(); |
| + if (!typeName.startsWith("_")) return false; |
| + return description.contains(".$type"); |
| + } |
| } |