Chromium Code Reviews| Index: reflectable/lib/src/transformer_implementation.dart |
| diff --git a/reflectable/lib/src/transformer_implementation.dart b/reflectable/lib/src/transformer_implementation.dart |
| index c04ae96570c5cfaaf7c2b6b4fbd5ef74ce99c758..beb9a8831e70a42d0f57c0bc23bbef3ca1d7e6e2 100644 |
| --- a/reflectable/lib/src/transformer_implementation.dart |
| +++ b/reflectable/lib/src/transformer_implementation.dart |
| @@ -364,7 +364,7 @@ class _ReflectorDomain { |
| final AssetId _generatedLibraryId; |
| final ClassElement _reflector; |
| - /// Do not use this, use [classes] which ensures that closures operations |
| + /// Do not use this, use [classes] which ensures that closure operations |
| /// have been performed as requested in [_capabilities]. Exception: In |
| /// `_computeWorld`, [_classes] is filled in with the set of directly |
| /// covered classes during creation of this [_ReflectorDomain]. |
| @@ -542,9 +542,10 @@ class _ReflectorDomain { |
| // Library and class related collections. |
| Enumerator<ExecutableElement> members = new Enumerator<ExecutableElement>(); |
| - // Fill in [libraries], [members], [fields], [parameters], |
| - // [instanceGetterNames], and [instanceSetterNames]. |
| - for (LibraryElement library in _libraries) { |
| + /// Adds a library domain for [library] to [libraries], relying on checks |
| + /// for importability and insertion into [importCollector] to have taken |
| + /// place already. |
| + void uncheckedAddLibrary(LibraryElement library) { |
| _LibraryDomain libraryDomain = _createLibraryDomain(library, this); |
| libraries.add(libraryDomain); |
| libraryMap[library] = libraryDomain; |
| @@ -552,6 +553,25 @@ class _ReflectorDomain { |
| libraryDomain._declaredParameters.forEach(parameters.add); |
| libraryDomain._declaredVariables.forEach(topLevelVariables.add); |
| } |
| + |
| + /// Used to add a library domain for [library] to [libraries], checking |
| + /// that it is importable and registering it with [importCollector]. |
| + void addLibrary(LibraryElement library) { |
| + if (!_isImportableLibrary( |
| + library, _generatedLibraryId, _resolver)) return; |
| + importCollector._addLibrary(library); |
| + uncheckedAddLibrary(library); |
| + } |
| + |
| + // Fill in [libraries], [members], [fields], [parameters], |
| + // [instanceGetterNames], and [instanceSetterNames]. |
| + _libraries.forEach(uncheckedAddLibrary); |
| + classes.forEach((ClassElement classElement) { |
| + if (!libraries.items.any((_LibraryDomain libraryDomain) => |
| + libraryDomain._libraryElement == classElement.library)) { |
| + addLibrary(classElement.library); |
| + } |
| + }); |
| for (_ClassDomain classDomain in classes.domains) { |
| // Gather the behavioral interface into [members]. Note that |
| // this includes implicitly generated getters and setters, but |
| @@ -868,14 +888,13 @@ class _ReflectorDomain { |
| int classIndex = classes.indexOf(classElement); |
| - String result = 'new r.ClassMirrorImpl(r"${classDomain._simpleName}", ' |
| + return 'new r.ClassMirrorImpl(r"${classDomain._simpleName}", ' |
| 'r"${_qualifiedName(classElement)}", $descriptor, $classIndex, ' |
| '${_constConstructionCode(importCollector)}, ' |
| '$declarationsCode, $instanceMembersCode, $staticMembersCode, ' |
| '$superclassIndex, $staticGettersCode, $staticSettersCode, ' |
| '$constructorsCode, $ownerIndex, $mixinIndex, ' |
| '$superinterfaceIndices, $classMetadataCode)'; |
| - return result; |
| } |
| String _methodMirrorCode( |
| @@ -963,7 +982,9 @@ class _ReflectorDomain { |
| String _typeCodeOfClass( |
| ClassElement classElement, _ImportCollector importCollector) { |
| - if (classElement is MixinApplication && classElement.declaredName == null) { |
| + if ((classElement is MixinApplication && |
| + classElement.declaredName == null) || |
| + classElement.isPrivate) { |
| return 'const r.FakeType(r"${_qualifiedName(classElement)}")'; |
| } |
| if (classElement.type.isDynamic) return "dynamic"; |
| @@ -1018,7 +1039,7 @@ class _ReflectorDomain { |
| // TODO(sigurdm) clarify: Find out how to get good uri's in a |
| // transformer. |
| // TODO(sigurdm) implement: Check for `uriCapability`. |
| - String uriCode = "null"; |
| + String uriCode = 'Uri.parse(r"reflectable://$library")'; |
|
sigurdm
2015/10/15 12:30:58
Is this any better?
eernst
2015/10/15 13:46:11
We cannot implement a map from `Uri` to `LibraryMi
|
| String metadataCode; |
| if (_capabilities._supportsMetadata) { |
| @@ -2284,7 +2305,7 @@ class TransformerImplementation { |
| void addLibrary(LibraryElement library, ClassElement reflector) { |
| _ReflectorDomain domain = getReflectorDomain(reflector); |
| if (domain._capabilities.supportsLibraries) { |
| - assert(_isImportableLibrary(reflector.library, dataId, _resolver)); |
| + assert(_isImportableLibrary(library, dataId, _resolver)); |
| importCollector._addLibrary(library); |
| domain._libraries.add(library); |
| } |
| @@ -2387,7 +2408,7 @@ class TransformerImplementation { |
| for (LibraryElement library in _resolver.libraries) { |
| for (ClassElement reflector |
| in getReflectors(library.name, library.metadata)) { |
| - assert(_isImportableLibrary(reflector.library, dataId, _resolver)); |
| + assert(_isImportableLibrary(library, dataId, _resolver)); |
| addLibrary(library, reflector); |
| } |