Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(820)

Side by Side Diff: pkg/analyzer/lib/src/summary/resynthesize.dart

Issue 1567583002: Tests for SummarySdkAnalysisContext. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Remove the SDK summary file from the repo. Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/summary/summary_sdk.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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';
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 * hasn't been resynthesized already. 111 * hasn't been resynthesized already.
112 */ 112 */
113 LibraryElement getLibraryElement(String uri) { 113 LibraryElement getLibraryElement(String uri) {
114 return _resynthesizedLibraries.putIfAbsent(uri, () { 114 return _resynthesizedLibraries.putIfAbsent(uri, () {
115 PrelinkedLibrary serializedLibrary = getPrelinkedSummary(uri); 115 PrelinkedLibrary serializedLibrary = getPrelinkedSummary(uri);
116 List<UnlinkedUnit> serializedUnits = <UnlinkedUnit>[ 116 List<UnlinkedUnit> serializedUnits = <UnlinkedUnit>[
117 getUnlinkedSummary(uri) 117 getUnlinkedSummary(uri)
118 ]; 118 ];
119 Source librarySource = _getSource(uri); 119 Source librarySource = _getSource(uri);
120 for (UnlinkedPart part in serializedUnits[0].publicNamespace.parts) { 120 for (UnlinkedPart part in serializedUnits[0].publicNamespace.parts) {
121 String partAbsUri = 121 Source partSource = sourceFactory.resolveUri(librarySource, part.uri);
122 sourceFactory.resolveUri(librarySource, part.uri).uri.toString(); 122 String partAbsUri = partSource.uri.toString();
123 serializedUnits.add(getUnlinkedSummary(partAbsUri)); 123 serializedUnits.add(getUnlinkedSummary(partAbsUri));
124 } 124 }
125 _LibraryResynthesizer libraryResynthesizer = new _LibraryResynthesizer( 125 _LibraryResynthesizer libraryResynthesizer = new _LibraryResynthesizer(
126 this, serializedLibrary, serializedUnits, librarySource); 126 this, serializedLibrary, serializedUnits, librarySource);
127 LibraryElement library = libraryResynthesizer.buildLibrary(); 127 LibraryElement library = libraryResynthesizer.buildLibrary();
128 _resynthesizedElements[uri] = libraryResynthesizer.resummarizedElements; 128 _resynthesizedElements[uri] = libraryResynthesizer.resummarizedElements;
129 return library; 129 return library;
130 }); 130 });
131 } 131 }
132 132
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 /** 712 /**
713 * Build a [DartType] object based on an [UnlinkedTypeRef]. This [DartType] 713 * Build a [DartType] object based on an [UnlinkedTypeRef]. This [DartType]
714 * may refer to elements in other libraries than the library being 714 * may refer to elements in other libraries than the library being
715 * deserialized, so handles are used to avoid having to deserialize other 715 * deserialized, so handles are used to avoid having to deserialize other
716 * libraries in the process. 716 * libraries in the process.
717 */ 717 */
718 DartType buildType(UnlinkedTypeRef type) { 718 DartType buildType(UnlinkedTypeRef type) {
719 if (type.paramReference != 0) { 719 if (type.paramReference != 0) {
720 // TODO(paulberry): make this work for generic methods. 720 // TODO(paulberry): make this work for generic methods.
721 return currentTypeParameters[ 721 return currentTypeParameters[
722 currentTypeParameters.length - type.paramReference].type; 722 currentTypeParameters.length - type.paramReference]
723 .type;
723 } else { 724 } else {
724 // TODO(paulberry): handle references to things other than classes (note: 725 // TODO(paulberry): handle references to things other than classes (note:
725 // this should only occur in the case of erroneous code). 726 // this should only occur in the case of erroneous code).
726 // TODO(paulberry): test reference to something inside a part. 727 // TODO(paulberry): test reference to something inside a part.
727 // TODO(paulberry): test reference to something inside a part of the 728 // TODO(paulberry): test reference to something inside a part of the
728 // current lib. 729 // current lib.
729 UnlinkedReference reference = unlinkedUnit.references[type.reference]; 730 UnlinkedReference reference = unlinkedUnit.references[type.reference];
730 PrelinkedReference referenceResolution = 731 PrelinkedReference referenceResolution =
731 prelinkedUnit.references[type.reference]; 732 prelinkedUnit.references[type.reference];
732 String referencedLibraryUri; 733 String referencedLibraryUri;
733 String partUri; 734 String partUri;
734 if (referenceResolution.dependency != 0) { 735 if (referenceResolution.dependency != 0) {
735 PrelinkedDependency dependency = 736 PrelinkedDependency dependency =
736 prelinkedLibrary.dependencies[referenceResolution.dependency]; 737 prelinkedLibrary.dependencies[referenceResolution.dependency];
737 Source referencedLibrarySource = summaryResynthesizer.sourceFactory 738 Source referencedLibrarySource = summaryResynthesizer.sourceFactory
738 .resolveUri(librarySource, dependency.uri); 739 .resolveUri(librarySource, dependency.uri);
739 referencedLibraryUri = referencedLibrarySource.uri.toString(); 740 referencedLibraryUri = referencedLibrarySource.uri.toString();
740 // TODO(paulberry): consider changing Location format so that this is 741 // TODO(paulberry): consider changing Location format so that this is
741 // not necessary (2nd string in location should just be the unit 742 // not necessary (2nd string in location should just be the unit
742 // number). 743 // number).
743 if (referenceResolution.unit != 0) { 744 if (referenceResolution.unit != 0) {
744 UnlinkedUnit referencedLibraryDefiningUnit = 745 UnlinkedUnit referencedLibraryDefiningUnit =
745 summaryResynthesizer.getUnlinkedSummary(referencedLibraryUri); 746 summaryResynthesizer.getUnlinkedSummary(referencedLibraryUri);
746 String uri = referencedLibraryDefiningUnit.publicNamespace.parts[ 747 String uri = referencedLibraryDefiningUnit
747 referenceResolution.unit - 1].uri; 748 .publicNamespace.parts[referenceResolution.unit - 1].uri;
748 Source partSource = summaryResynthesizer.sourceFactory 749 Source partSource = summaryResynthesizer.sourceFactory
749 .resolveUri(referencedLibrarySource, uri); 750 .resolveUri(referencedLibrarySource, uri);
750 partUri = partSource.uri.toString(); 751 partUri = partSource.uri.toString();
751 } else { 752 } else {
752 partUri = referencedLibraryUri; 753 partUri = referencedLibraryUri;
753 } 754 }
754 } else if (referenceResolution.kind == 755 } else if (referenceResolution.kind ==
755 PrelinkedReferenceKind.unresolved) { 756 PrelinkedReferenceKind.unresolved) {
756 return summaryResynthesizer.typeProvider.undefinedType; 757 return summaryResynthesizer.typeProvider.undefinedType;
757 } else if (reference.name.isEmpty) { 758 } else if (reference.name.isEmpty) {
758 return summaryResynthesizer.typeProvider.dynamicType; 759 return summaryResynthesizer.typeProvider.dynamicType;
759 } else { 760 } else {
760 referencedLibraryUri = librarySource.uri.toString(); 761 referencedLibraryUri = librarySource.uri.toString();
761 if (referenceResolution.unit != 0) { 762 if (referenceResolution.unit != 0) {
762 String uri = unlinkedUnits[0].publicNamespace.parts[ 763 String uri = unlinkedUnits[0]
763 referenceResolution.unit - 1].uri; 764 .publicNamespace
765 .parts[referenceResolution.unit - 1]
766 .uri;
764 Source partSource = 767 Source partSource =
765 summaryResynthesizer.sourceFactory.resolveUri(librarySource, uri); 768 summaryResynthesizer.sourceFactory.resolveUri(librarySource, uri);
766 partUri = partSource.uri.toString(); 769 partUri = partSource.uri.toString();
767 } else { 770 } else {
768 partUri = referencedLibraryUri; 771 partUri = referencedLibraryUri;
769 } 772 }
770 } 773 }
771 ElementLocationImpl location = new ElementLocationImpl.con3( 774 ElementLocationImpl location = new ElementLocationImpl.con3(
772 <String>[referencedLibraryUri, partUri, reference.name]); 775 <String>[referencedLibraryUri, partUri, reference.name]);
773 List<DartType> typeArguments = const <DartType>[]; 776 List<DartType> typeArguments = const <DartType>[];
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
923 } 926 }
924 for (FunctionTypeAliasElement typeAlias in unit.functionTypeAliases) { 927 for (FunctionTypeAliasElement typeAlias in unit.functionTypeAliases) {
925 elementMap[typeAlias.name] = typeAlias; 928 elementMap[typeAlias.name] = typeAlias;
926 } 929 }
927 resummarizedElements[absoluteUri] = elementMap; 930 resummarizedElements[absoluteUri] = elementMap;
928 unitHolder = null; 931 unitHolder = null;
929 prelinkedUnit = null; 932 prelinkedUnit = null;
930 unlinkedUnit = null; 933 unlinkedUnit = null;
931 } 934 }
932 } 935 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/summary/summary_sdk.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698