| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 library summary_resynthesizer; | 5 library summary_resynthesizer; |
| 6 | 6 |
| 7 import 'package:analyzer/analyzer.dart'; | 7 import 'package:analyzer/analyzer.dart'; |
| 8 import 'package:analyzer/src/generated/element.dart'; | 8 import 'package:analyzer/src/generated/element.dart'; |
| 9 import 'package:analyzer/src/generated/element_handle.dart'; | 9 import 'package:analyzer/src/generated/element_handle.dart'; |
| 10 import 'package:analyzer/src/generated/engine.dart'; | 10 import 'package:analyzer/src/generated/engine.dart'; |
| 11 import 'package:analyzer/src/generated/resolver.dart'; | 11 import 'package:analyzer/src/generated/resolver.dart'; |
| 12 import 'package:analyzer/src/generated/source_io.dart'; | 12 import 'package:analyzer/src/generated/source_io.dart'; |
| 13 import 'package:analyzer/src/summary/format.dart'; | 13 import 'package:analyzer/src/summary/format.dart'; |
| 14 | 14 |
| 15 /** | 15 /** |
| 16 * Callback used by [SummaryResynthesizer] to obtain the summary for a given | 16 * Callback used by [SummaryResynthesizer] to obtain the prelinked summary for |
| 17 * URI. | 17 * a given URI. |
| 18 */ | 18 */ |
| 19 typedef PrelinkedLibrary GetSummaryCallback(String uri); | 19 typedef PrelinkedLibrary GetPrelinkedSummaryCallback(String uri); |
| 20 |
| 21 /** |
| 22 * Callback used by [SummaryResynthesizer] to obtain the unlinked summary for a |
| 23 * given URI. |
| 24 */ |
| 25 typedef UnlinkedUnit GetUnlinkedSummaryCallback(String uri); |
| 20 | 26 |
| 21 /** | 27 /** |
| 22 * Specialization of [FunctionTypeImpl] used for function types resynthesized | 28 * Specialization of [FunctionTypeImpl] used for function types resynthesized |
| 23 * from summaries. | 29 * from summaries. |
| 24 */ | 30 */ |
| 25 class ResynthesizedFunctionTypeImpl extends FunctionTypeImpl | 31 class ResynthesizedFunctionTypeImpl extends FunctionTypeImpl |
| 26 with ResynthesizedType { | 32 with ResynthesizedType { |
| 27 final SummaryResynthesizer summaryResynthesizer; | 33 final SummaryResynthesizer summaryResynthesizer; |
| 28 | 34 |
| 29 ResynthesizedFunctionTypeImpl( | 35 ResynthesizedFunctionTypeImpl( |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 | 83 |
| 78 int get _numTypeParameters; | 84 int get _numTypeParameters; |
| 79 } | 85 } |
| 80 | 86 |
| 81 /** | 87 /** |
| 82 * Implementation of [ElementResynthesizer] used when resynthesizing an element | 88 * Implementation of [ElementResynthesizer] used when resynthesizing an element |
| 83 * model from summaries. | 89 * model from summaries. |
| 84 */ | 90 */ |
| 85 class SummaryResynthesizer extends ElementResynthesizer { | 91 class SummaryResynthesizer extends ElementResynthesizer { |
| 86 /** | 92 /** |
| 87 * Callback used to obtain the summary for a given URI. | 93 * Callback used to obtain the prelinked summary for a given URI. |
| 88 */ | 94 */ |
| 89 final GetSummaryCallback getSummary; | 95 final GetPrelinkedSummaryCallback getPrelinkedSummary; |
| 96 |
| 97 /** |
| 98 * Callback used to obtain the unlinked summary for a given URI. |
| 99 */ |
| 100 final GetUnlinkedSummaryCallback getUnlinkedSummary; |
| 90 | 101 |
| 91 /** | 102 /** |
| 92 * Source factory used to convert URIs to [Source] objects. | 103 * Source factory used to convert URIs to [Source] objects. |
| 93 */ | 104 */ |
| 94 final SourceFactory sourceFactory; | 105 final SourceFactory sourceFactory; |
| 95 | 106 |
| 96 /** | 107 /** |
| 97 * Cache of [Source] objects that have already been converted from URIs. | 108 * Cache of [Source] objects that have already been converted from URIs. |
| 98 */ | 109 */ |
| 99 final Map<String, Source> _sources = <String, Source>{}; | 110 final Map<String, Source> _sources = <String, Source>{}; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 115 final Map<String, Map<String, Map<String, Element>>> _resynthesizedElements = | 126 final Map<String, Map<String, Map<String, Element>>> _resynthesizedElements = |
| 116 <String, Map<String, Map<String, Element>>>{}; | 127 <String, Map<String, Map<String, Element>>>{}; |
| 117 | 128 |
| 118 /** | 129 /** |
| 119 * Map of libraries which have been resynthesized from summaries. The map | 130 * Map of libraries which have been resynthesized from summaries. The map |
| 120 * key is the library URI. | 131 * key is the library URI. |
| 121 */ | 132 */ |
| 122 final Map<String, LibraryElement> _resynthesizedLibraries = | 133 final Map<String, LibraryElement> _resynthesizedLibraries = |
| 123 <String, LibraryElement>{}; | 134 <String, LibraryElement>{}; |
| 124 | 135 |
| 125 SummaryResynthesizer( | 136 SummaryResynthesizer(AnalysisContext context, this.getPrelinkedSummary, |
| 126 AnalysisContext context, this.getSummary, this.sourceFactory) | 137 this.getUnlinkedSummary, this.sourceFactory) |
| 127 : super(context), | 138 : super(context), |
| 128 typeProvider = context.typeProvider; | 139 typeProvider = context.typeProvider; |
| 129 | 140 |
| 130 /** | 141 /** |
| 131 * Number of libraries that have been resynthesized so far. | 142 * Number of libraries that have been resynthesized so far. |
| 132 */ | 143 */ |
| 133 int get resynthesisCount => _resynthesizedLibraries.length; | 144 int get resynthesisCount => _resynthesizedLibraries.length; |
| 134 | 145 |
| 135 @override | 146 @override |
| 136 Element getElement(ElementLocation location) { | 147 Element getElement(ElementLocation location) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 158 throw new UnimplementedError(location.toString()); | 169 throw new UnimplementedError(location.toString()); |
| 159 } | 170 } |
| 160 } | 171 } |
| 161 | 172 |
| 162 /** | 173 /** |
| 163 * Get the [LibraryElement] for the given [uri], resynthesizing it if it | 174 * Get the [LibraryElement] for the given [uri], resynthesizing it if it |
| 164 * hasn't been resynthesized already. | 175 * hasn't been resynthesized already. |
| 165 */ | 176 */ |
| 166 LibraryElement getLibraryElement(String uri) { | 177 LibraryElement getLibraryElement(String uri) { |
| 167 return _resynthesizedLibraries.putIfAbsent(uri, () { | 178 return _resynthesizedLibraries.putIfAbsent(uri, () { |
| 168 PrelinkedLibrary serializedLibrary = getSummary(uri); | 179 PrelinkedLibrary serializedLibrary = getPrelinkedSummary(uri); |
| 169 _LibraryResynthesizer libraryResynthesizer = | 180 List<UnlinkedUnit> serializedUnits = <UnlinkedUnit>[ |
| 170 new _LibraryResynthesizer(this, serializedLibrary, _getSource(uri)); | 181 getUnlinkedSummary(uri) |
| 182 ]; |
| 183 Source librarySource = _getSource(uri); |
| 184 for (UnlinkedPart part in serializedUnits[0].parts) { |
| 185 String partAbsUri = |
| 186 sourceFactory.resolveUri(librarySource, part.uri).uri.toString(); |
| 187 serializedUnits.add(getUnlinkedSummary(partAbsUri)); |
| 188 } |
| 189 _LibraryResynthesizer libraryResynthesizer = new _LibraryResynthesizer( |
| 190 this, serializedLibrary, serializedUnits, librarySource); |
| 171 LibraryElement library = libraryResynthesizer.buildLibrary(); | 191 LibraryElement library = libraryResynthesizer.buildLibrary(); |
| 172 _resynthesizedElements[uri] = libraryResynthesizer.resummarizedElements; | 192 _resynthesizedElements[uri] = libraryResynthesizer.resummarizedElements; |
| 173 return library; | 193 return library; |
| 174 }); | 194 }); |
| 175 } | 195 } |
| 176 | 196 |
| 177 /** | 197 /** |
| 178 * Get the [Source] object for the given [uri]. | 198 * Get the [Source] object for the given [uri]. |
| 179 */ | 199 */ |
| 180 Source _getSource(String uri) { | 200 Source _getSource(String uri) { |
| 181 return _sources.putIfAbsent(uri, () => sourceFactory.forUri(uri)); | 201 return _sources.putIfAbsent(uri, () => sourceFactory.forUri(uri)); |
| 182 } | 202 } |
| 183 } | 203 } |
| 184 | 204 |
| 185 /** | 205 /** |
| 186 * An instance of [_LibraryResynthesizer] is responsible for resynthesizing the | 206 * An instance of [_LibraryResynthesizer] is responsible for resynthesizing the |
| 187 * elements in a single library from that library's summary. | 207 * elements in a single library from that library's summary. |
| 188 */ | 208 */ |
| 189 class _LibraryResynthesizer { | 209 class _LibraryResynthesizer { |
| 190 /** | 210 /** |
| 191 * The [SummaryResynthesizer] which is being used to obtain summaries. | 211 * The [SummaryResynthesizer] which is being used to obtain summaries. |
| 192 */ | 212 */ |
| 193 final SummaryResynthesizer summaryResynthesizer; | 213 final SummaryResynthesizer summaryResynthesizer; |
| 194 | 214 |
| 195 /** | 215 /** |
| 196 * The library to be resynthesized. | 216 * Prelinked summary of the library to be resynthesized. |
| 197 */ | 217 */ |
| 198 final PrelinkedLibrary prelinkedLibrary; | 218 final PrelinkedLibrary prelinkedLibrary; |
| 199 | 219 |
| 200 /** | 220 /** |
| 221 * Unlinked compilation units constituting the library to be resynthesized. |
| 222 */ |
| 223 final List<UnlinkedUnit> unlinkedUnits; |
| 224 |
| 225 /** |
| 201 * [Source] object for the library to be resynthesized. | 226 * [Source] object for the library to be resynthesized. |
| 202 */ | 227 */ |
| 203 final Source librarySource; | 228 final Source librarySource; |
| 204 | 229 |
| 205 /** | 230 /** |
| 206 * [ElementHolder] into which resynthesized elements should be placed. This | 231 * [ElementHolder] into which resynthesized elements should be placed. This |
| 207 * object is recreated afresh for each unit in the library, and is used to | 232 * object is recreated afresh for each unit in the library, and is used to |
| 208 * populate the [CompilationUnitElement]. | 233 * populate the [CompilationUnitElement]. |
| 209 */ | 234 */ |
| 210 ElementHolder unitHolder; | 235 ElementHolder unitHolder; |
| 211 | 236 |
| 212 /** | 237 /** |
| 213 * The [PrelinkedUnit] from which elements are currently being resynthesized. | 238 * The [PrelinkedUnit] from which elements are currently being resynthesized. |
| 214 */ | 239 */ |
| 215 PrelinkedUnit prelinkedUnit; | 240 PrelinkedUnit prelinkedUnit; |
| 216 | 241 |
| 217 /** | 242 /** |
| 243 * The [UnlinkedUnit] from which elements are currently being resynthesized. |
| 244 */ |
| 245 UnlinkedUnit unlinkedUnit; |
| 246 |
| 247 /** |
| 218 * Map of top level elements that have been resynthesized so far. The first | 248 * Map of top level elements that have been resynthesized so far. The first |
| 219 * key is the URI of the compilation unit; the second is the name of the top | 249 * key is the URI of the compilation unit; the second is the name of the top |
| 220 * level element. | 250 * level element. |
| 221 */ | 251 */ |
| 222 final Map<String, Map<String, Element>> resummarizedElements = | 252 final Map<String, Map<String, Element>> resummarizedElements = |
| 223 <String, Map<String, Element>>{}; | 253 <String, Map<String, Element>>{}; |
| 224 | 254 |
| 225 /** | 255 /** |
| 226 * Type parameters for the class or typedef currently being resynthesized. | 256 * Type parameters for the class or typedef currently being resynthesized. |
| 227 * | 257 * |
| 228 * TODO(paulberry): extend this to do the right thing for generic methods. | 258 * TODO(paulberry): extend this to do the right thing for generic methods. |
| 229 */ | 259 */ |
| 230 List<TypeParameterElement> currentTypeParameters; | 260 List<TypeParameterElement> currentTypeParameters; |
| 231 | 261 |
| 232 _LibraryResynthesizer(this.summaryResynthesizer, | 262 _LibraryResynthesizer(this.summaryResynthesizer, this.prelinkedLibrary, |
| 233 PrelinkedLibrary serializedLibrary, this.librarySource) | 263 this.unlinkedUnits, this.librarySource); |
| 234 : prelinkedLibrary = serializedLibrary; | |
| 235 | 264 |
| 236 /** | 265 /** |
| 237 * Resynthesize a [ClassElement] and place it in [unitHolder]. | 266 * Resynthesize a [ClassElement] and place it in [unitHolder]. |
| 238 */ | 267 */ |
| 239 void buildClass(UnlinkedClass serializedClass) { | 268 void buildClass(UnlinkedClass serializedClass) { |
| 240 try { | 269 try { |
| 241 currentTypeParameters = | 270 currentTypeParameters = |
| 242 serializedClass.typeParameters.map(buildTypeParameter).toList(); | 271 serializedClass.typeParameters.map(buildTypeParameter).toList(); |
| 243 for (int i = 0; i < serializedClass.typeParameters.length; i++) { | 272 for (int i = 0; i < serializedClass.typeParameters.length; i++) { |
| 244 finishTypeParameter( | 273 finishTypeParameter( |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 595 .toString(); | 624 .toString(); |
| 596 importElement.importedLibrary = new LibraryElementHandle( | 625 importElement.importedLibrary = new LibraryElementHandle( |
| 597 summaryResynthesizer, | 626 summaryResynthesizer, |
| 598 new ElementLocationImpl.con3(<String>[absoluteUri])); | 627 new ElementLocationImpl.con3(<String>[absoluteUri])); |
| 599 if (isSynthetic) { | 628 if (isSynthetic) { |
| 600 importElement.synthetic = true; | 629 importElement.synthetic = true; |
| 601 } else { | 630 } else { |
| 602 importElement.uri = serializedImport.uri; | 631 importElement.uri = serializedImport.uri; |
| 603 } | 632 } |
| 604 if (serializedImport.prefixReference != 0) { | 633 if (serializedImport.prefixReference != 0) { |
| 605 UnlinkedReference serializedPrefix = prelinkedLibrary.units[0] | 634 UnlinkedReference serializedPrefix = |
| 606 .unlinked | 635 unlinkedUnits[0].references[serializedImport.prefixReference]; |
| 607 .references[serializedImport.prefixReference]; | |
| 608 importElement.prefix = new PrefixElementImpl(serializedPrefix.name, -1); | 636 importElement.prefix = new PrefixElementImpl(serializedPrefix.name, -1); |
| 609 } | 637 } |
| 610 importElement.combinators = | 638 importElement.combinators = |
| 611 serializedImport.combinators.map(buildCombinator).toList(); | 639 serializedImport.combinators.map(buildCombinator).toList(); |
| 612 return importElement; | 640 return importElement; |
| 613 } | 641 } |
| 614 | 642 |
| 615 /** | 643 /** |
| 616 * Main entry point. Resynthesize the [LibraryElement] and return it. | 644 * Main entry point. Resynthesize the [LibraryElement] and return it. |
| 617 */ | 645 */ |
| 618 LibraryElement buildLibrary() { | 646 LibraryElement buildLibrary() { |
| 619 // TODO(paulberry): is it ok to pass -1 for offset and nameLength? | 647 // TODO(paulberry): is it ok to pass -1 for offset and nameLength? |
| 620 LibraryElementImpl libraryElement = new LibraryElementImpl( | 648 LibraryElementImpl libraryElement = new LibraryElementImpl( |
| 621 summaryResynthesizer.context, | 649 summaryResynthesizer.context, unlinkedUnits[0].libraryName, -1, -1); |
| 622 prelinkedLibrary.units[0].unlinked.libraryName, | |
| 623 -1, | |
| 624 -1); | |
| 625 CompilationUnitElementImpl definingCompilationUnit = | 650 CompilationUnitElementImpl definingCompilationUnit = |
| 626 new CompilationUnitElementImpl(librarySource.shortName); | 651 new CompilationUnitElementImpl(librarySource.shortName); |
| 627 libraryElement.definingCompilationUnit = definingCompilationUnit; | 652 libraryElement.definingCompilationUnit = definingCompilationUnit; |
| 628 definingCompilationUnit.source = librarySource; | 653 definingCompilationUnit.source = librarySource; |
| 629 definingCompilationUnit.librarySource = librarySource; | 654 definingCompilationUnit.librarySource = librarySource; |
| 630 List<CompilationUnitElement> parts = <CompilationUnitElement>[]; | 655 List<CompilationUnitElement> parts = <CompilationUnitElement>[]; |
| 631 UnlinkedUnit unlinkedDefiningUnit = prelinkedLibrary.units[0].unlinked; | 656 UnlinkedUnit unlinkedDefiningUnit = unlinkedUnits[0]; |
| 632 assert( | 657 assert( |
| 633 unlinkedDefiningUnit.parts.length + 1 == prelinkedLibrary.units.length); | 658 unlinkedDefiningUnit.parts.length + 1 == prelinkedLibrary.units.length); |
| 634 for (int i = 1; i < prelinkedLibrary.units.length; i++) { | 659 for (int i = 1; i < prelinkedLibrary.units.length; i++) { |
| 635 CompilationUnitElementImpl part = buildPart( | 660 CompilationUnitElementImpl part = |
| 636 unlinkedDefiningUnit.parts[i - 1].uri, | 661 buildPart(unlinkedDefiningUnit.parts[i - 1].uri, unlinkedUnits[i]); |
| 637 prelinkedLibrary.units[i].unlinked); | |
| 638 parts.add(part); | 662 parts.add(part); |
| 639 } | 663 } |
| 640 libraryElement.parts = parts; | 664 libraryElement.parts = parts; |
| 641 List<ImportElement> imports = <ImportElement>[]; | 665 List<ImportElement> imports = <ImportElement>[]; |
| 642 for (int i = 0; i < unlinkedDefiningUnit.imports.length; i++) { | 666 for (int i = 0; i < unlinkedDefiningUnit.imports.length; i++) { |
| 643 imports.add(buildImport(unlinkedDefiningUnit.imports[i], | 667 imports.add(buildImport(unlinkedDefiningUnit.imports[i], |
| 644 prelinkedLibrary.importDependencies[i])); | 668 prelinkedLibrary.importDependencies[i])); |
| 645 } | 669 } |
| 646 libraryElement.imports = imports; | 670 libraryElement.imports = imports; |
| 647 libraryElement.exports = | 671 libraryElement.exports = |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 717 if (type.paramReference != 0) { | 741 if (type.paramReference != 0) { |
| 718 // TODO(paulberry): make this work for generic methods. | 742 // TODO(paulberry): make this work for generic methods. |
| 719 return currentTypeParameters[ | 743 return currentTypeParameters[ |
| 720 currentTypeParameters.length - type.paramReference].type; | 744 currentTypeParameters.length - type.paramReference].type; |
| 721 } else { | 745 } else { |
| 722 // TODO(paulberry): handle references to things other than classes (note: | 746 // TODO(paulberry): handle references to things other than classes (note: |
| 723 // this should only occur in the case of erroneous code). | 747 // this should only occur in the case of erroneous code). |
| 724 // TODO(paulberry): test reference to something inside a part. | 748 // TODO(paulberry): test reference to something inside a part. |
| 725 // TODO(paulberry): test reference to something inside a part of the | 749 // TODO(paulberry): test reference to something inside a part of the |
| 726 // current lib. | 750 // current lib. |
| 727 UnlinkedReference reference = | 751 UnlinkedReference reference = unlinkedUnit.references[type.reference]; |
| 728 prelinkedUnit.unlinked.references[type.reference]; | |
| 729 PrelinkedReference referenceResolution = | 752 PrelinkedReference referenceResolution = |
| 730 prelinkedUnit.references[type.reference]; | 753 prelinkedUnit.references[type.reference]; |
| 731 String referencedLibraryUri; | 754 String referencedLibraryUri; |
| 732 String partUri; | 755 String partUri; |
| 733 if (referenceResolution.dependency != 0) { | 756 if (referenceResolution.dependency != 0) { |
| 734 PrelinkedDependency dependency = | 757 PrelinkedDependency dependency = |
| 735 prelinkedLibrary.dependencies[referenceResolution.dependency]; | 758 prelinkedLibrary.dependencies[referenceResolution.dependency]; |
| 736 Source referencedLibrarySource = summaryResynthesizer.sourceFactory | 759 Source referencedLibrarySource = summaryResynthesizer.sourceFactory |
| 737 .resolveUri(librarySource, dependency.uri); | 760 .resolveUri(librarySource, dependency.uri); |
| 738 referencedLibraryUri = referencedLibrarySource.uri.toString(); | 761 referencedLibraryUri = referencedLibrarySource.uri.toString(); |
| 739 PrelinkedLibrary referencedLibrary = | |
| 740 summaryResynthesizer.getSummary(referencedLibraryUri); | |
| 741 // TODO(paulberry): consider changing Location format so that this is | 762 // TODO(paulberry): consider changing Location format so that this is |
| 742 // not necessary (2nd string in location should just be the unit | 763 // not necessary (2nd string in location should just be the unit |
| 743 // number). | 764 // number). |
| 744 if (referenceResolution.unit != 0) { | 765 if (referenceResolution.unit != 0) { |
| 745 String uri = referencedLibrary.units[0].unlinked.parts[0].uri; | 766 UnlinkedUnit referencedLibraryDefiningUnit = |
| 767 summaryResynthesizer.getUnlinkedSummary(referencedLibraryUri); |
| 768 String uri = referencedLibraryDefiningUnit.parts[0].uri; |
| 746 Source partSource = summaryResynthesizer.sourceFactory | 769 Source partSource = summaryResynthesizer.sourceFactory |
| 747 .resolveUri(referencedLibrarySource, uri); | 770 .resolveUri(referencedLibrarySource, uri); |
| 748 partUri = partSource.uri.toString(); | 771 partUri = partSource.uri.toString(); |
| 749 } else { | 772 } else { |
| 750 partUri = referencedLibraryUri; | 773 partUri = referencedLibraryUri; |
| 751 } | 774 } |
| 752 } else if (referenceResolution.kind == | 775 } else if (referenceResolution.kind == |
| 753 PrelinkedReferenceKind.unresolved) { | 776 PrelinkedReferenceKind.unresolved) { |
| 754 return summaryResynthesizer.typeProvider.undefinedType; | 777 return summaryResynthesizer.typeProvider.undefinedType; |
| 755 } else if (reference.name.isEmpty) { | 778 } else if (reference.name.isEmpty) { |
| 756 return summaryResynthesizer.typeProvider.dynamicType; | 779 return summaryResynthesizer.typeProvider.dynamicType; |
| 757 } else { | 780 } else { |
| 758 referencedLibraryUri = librarySource.uri.toString(); | 781 referencedLibraryUri = librarySource.uri.toString(); |
| 759 if (referenceResolution.unit != 0) { | 782 if (referenceResolution.unit != 0) { |
| 760 String uri = prelinkedLibrary.units[0].unlinked.parts[ | 783 String uri = unlinkedUnits[0].parts[referenceResolution.unit - 1].uri; |
| 761 referenceResolution.unit - 1].uri; | |
| 762 Source partSource = | 784 Source partSource = |
| 763 summaryResynthesizer.sourceFactory.resolveUri(librarySource, uri); | 785 summaryResynthesizer.sourceFactory.resolveUri(librarySource, uri); |
| 764 partUri = partSource.uri.toString(); | 786 partUri = partSource.uri.toString(); |
| 765 } else { | 787 } else { |
| 766 partUri = referencedLibraryUri; | 788 partUri = referencedLibraryUri; |
| 767 } | 789 } |
| 768 } | 790 } |
| 769 ResynthesizedType resynthesizedType; | 791 ResynthesizedType resynthesizedType; |
| 770 ElementLocationImpl location = new ElementLocationImpl.con3( | 792 ElementLocationImpl location = new ElementLocationImpl.con3( |
| 771 <String>[referencedLibraryUri, partUri, reference.name]); | 793 <String>[referencedLibraryUri, partUri, reference.name]); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 882 typeParameterElement.bound = buildType(serializedTypeParameter.bound); | 904 typeParameterElement.bound = buildType(serializedTypeParameter.bound); |
| 883 } | 905 } |
| 884 } | 906 } |
| 885 | 907 |
| 886 /** | 908 /** |
| 887 * Populate a [CompilationUnitElement] by deserializing all the elements | 909 * Populate a [CompilationUnitElement] by deserializing all the elements |
| 888 * contained in it. | 910 * contained in it. |
| 889 */ | 911 */ |
| 890 void populateUnit(CompilationUnitElementImpl unit, int unitNum) { | 912 void populateUnit(CompilationUnitElementImpl unit, int unitNum) { |
| 891 prelinkedUnit = prelinkedLibrary.units[unitNum]; | 913 prelinkedUnit = prelinkedLibrary.units[unitNum]; |
| 914 unlinkedUnit = unlinkedUnits[unitNum]; |
| 892 unitHolder = new ElementHolder(); | 915 unitHolder = new ElementHolder(); |
| 893 UnlinkedUnit unlinkedUnit = prelinkedUnit.unlinked; | |
| 894 unlinkedUnit.classes.forEach(buildClass); | 916 unlinkedUnit.classes.forEach(buildClass); |
| 895 unlinkedUnit.enums.forEach(buildEnum); | 917 unlinkedUnit.enums.forEach(buildEnum); |
| 896 unlinkedUnit.executables.forEach(buildExecutable); | 918 unlinkedUnit.executables.forEach(buildExecutable); |
| 897 unlinkedUnit.typedefs.forEach(buildTypedef); | 919 unlinkedUnit.typedefs.forEach(buildTypedef); |
| 898 unlinkedUnit.variables.forEach(buildVariable); | 920 unlinkedUnit.variables.forEach(buildVariable); |
| 899 String absoluteUri = unit.source.uri.toString(); | 921 String absoluteUri = unit.source.uri.toString(); |
| 900 unit.accessors = unitHolder.accessors; | 922 unit.accessors = unitHolder.accessors; |
| 901 unit.enums = unitHolder.enums; | 923 unit.enums = unitHolder.enums; |
| 902 unit.functions = unitHolder.functions; | 924 unit.functions = unitHolder.functions; |
| 903 List<FunctionTypeAliasElement> typeAliases = unitHolder.typeAliases; | 925 List<FunctionTypeAliasElement> typeAliases = unitHolder.typeAliases; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 915 } | 937 } |
| 916 for (ClassElement cls in unit.enums) { | 938 for (ClassElement cls in unit.enums) { |
| 917 elementMap[cls.name] = cls; | 939 elementMap[cls.name] = cls; |
| 918 } | 940 } |
| 919 for (FunctionTypeAliasElement typeAlias in unit.functionTypeAliases) { | 941 for (FunctionTypeAliasElement typeAlias in unit.functionTypeAliases) { |
| 920 elementMap[typeAlias.name] = typeAlias; | 942 elementMap[typeAlias.name] = typeAlias; |
| 921 } | 943 } |
| 922 resummarizedElements[absoluteUri] = elementMap; | 944 resummarizedElements[absoluteUri] = elementMap; |
| 923 unitHolder = null; | 945 unitHolder = null; |
| 924 prelinkedUnit = null; | 946 prelinkedUnit = null; |
| 947 unlinkedUnit = null; |
| 925 } | 948 } |
| 926 } | 949 } |
| OLD | NEW |