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

Side by Side Diff: pkg/analyzer/test/src/summary/resynthesize_ast_test.dart

Issue 2353433002: Use configurations and declared variables to select import/export URIs during prelinking. (Closed)
Patch Set: Cache selected URI. Created 4 years, 3 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
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 analyzer.test.src.summary.resynthesize_ast_test; 5 library analyzer.test.src.summary.resynthesize_ast_test;
6 6
7 import 'package:analyzer/dart/ast/ast.dart'; 7 import 'package:analyzer/dart/ast/ast.dart';
8 import 'package:analyzer/dart/element/element.dart'; 8 import 'package:analyzer/dart/element/element.dart';
9 import 'package:analyzer/src/dart/element/element.dart'; 9 import 'package:analyzer/src/dart/element/element.dart';
10 import 'package:analyzer/src/generated/engine.dart' 10 import 'package:analyzer/src/generated/engine.dart'
(...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 755
756 UnlinkedUnit getUnit(String absoluteUri) { 756 UnlinkedUnit getUnit(String absoluteUri) {
757 UnlinkedUnit unit = uriToUnit[absoluteUri] ?? 757 UnlinkedUnit unit = uriToUnit[absoluteUri] ??
758 SerializedMockSdk.instance.uriToUnlinkedUnit[absoluteUri]; 758 SerializedMockSdk.instance.uriToUnlinkedUnit[absoluteUri];
759 if (unit == null && !allowMissingFiles) { 759 if (unit == null && !allowMissingFiles) {
760 fail('Linker unexpectedly requested unit for "$absoluteUri".'); 760 fail('Linker unexpectedly requested unit for "$absoluteUri".');
761 } 761 }
762 return unit; 762 return unit;
763 } 763 }
764 764
765 Set<String> nonSdkLibraryUris = context.sources 765 Set<String> nonSdkLibraryUris = serializedSources
766 .where((Source source) => 766 .where((Source source) =>
767 !source.isInSystemLibrary && 767 !source.isInSystemLibrary &&
768 context.computeKindOf(source) == SourceKind.LIBRARY) 768 context.computeKindOf(source) == SourceKind.LIBRARY)
769 .map((Source source) => source.uri.toString()) 769 .map((Source source) => source.uri.toString())
770 .toSet(); 770 .toSet();
771 771
772 Map<String, LinkedLibrary> linkedSummaries = link(nonSdkLibraryUris, 772 Map<String, LinkedLibrary> linkedSummaries = link(
773 getDependency, getUnit, context.analysisOptions.strongMode); 773 nonSdkLibraryUris,
774 getDependency,
775 getUnit,
776 context.declaredVariables.get,
777 context.analysisOptions.strongMode);
774 778
775 return new TestSummaryResynthesizer( 779 return new TestSummaryResynthesizer(
776 null, 780 null,
777 context, 781 context,
778 new Map<String, UnlinkedUnit>() 782 new Map<String, UnlinkedUnit>()
779 ..addAll(SerializedMockSdk.instance.uriToUnlinkedUnit) 783 ..addAll(SerializedMockSdk.instance.uriToUnlinkedUnit)
780 ..addAll(unlinkedSummaries), 784 ..addAll(unlinkedSummaries),
781 new Map<String, LinkedLibrary>() 785 new Map<String, LinkedLibrary>()
782 ..addAll(SerializedMockSdk.instance.uriToLinkedLibrary) 786 ..addAll(SerializedMockSdk.instance.uriToLinkedLibrary)
783 ..addAll(linkedSummaries), 787 ..addAll(linkedSummaries),
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 UnlinkedUnit getPart(String relativeUri) { 840 UnlinkedUnit getPart(String relativeUri) {
837 return _getUnlinkedUnit(resolveRelativeUri(relativeUri)); 841 return _getUnlinkedUnit(resolveRelativeUri(relativeUri));
838 } 842 }
839 843
840 UnlinkedPublicNamespace getImport(String relativeUri) { 844 UnlinkedPublicNamespace getImport(String relativeUri) {
841 return getPart(relativeUri)?.publicNamespace; 845 return getPart(relativeUri)?.publicNamespace;
842 } 846 }
843 847
844 UnlinkedUnit definingUnit = _getUnlinkedUnit(librarySource); 848 UnlinkedUnit definingUnit = _getUnlinkedUnit(librarySource);
845 if (definingUnit != null) { 849 if (definingUnit != null) {
846 LinkedLibraryBuilder linkedLibrary = 850 LinkedLibraryBuilder linkedLibrary = prelink(
847 prelink(definingUnit, getPart, getImport); 851 definingUnit, getPart, getImport, context.declaredVariables.get);
848 linkedLibrary.dependencies.skip(1).forEach((LinkedDependency d) { 852 linkedLibrary.dependencies.skip(1).forEach((LinkedDependency d) {
849 _serializeLibrary(resolveRelativeUri(d.uri)); 853 _serializeLibrary(resolveRelativeUri(d.uri));
850 }); 854 });
851 } 855 }
852 } 856 }
853 } 857 }
854 858
855 /** 859 /**
856 * Interface that [_AstResynthesizeTestMixin] requires of classes it's mixed 860 * Interface that [_AstResynthesizeTestMixin] requires of classes it's mixed
857 * into. We can't place the getter below into [_AstResynthesizeTestMixin] 861 * into. We can't place the getter below into [_AstResynthesizeTestMixin]
858 * directly, because then it would be overriding a field at the site where the 862 * directly, because then it would be overriding a field at the site where the
859 * mixin is instantiated. 863 * mixin is instantiated.
860 */ 864 */
861 abstract class _AstResynthesizeTestMixinInterface { 865 abstract class _AstResynthesizeTestMixinInterface {
862 /** 866 /**
863 * A test should return `true` to indicate that a missing file at the time of 867 * A test should return `true` to indicate that a missing file at the time of
864 * summary resynthesis shouldn't trigger an error. 868 * summary resynthesis shouldn't trigger an error.
865 */ 869 */
866 bool get allowMissingFiles; 870 bool get allowMissingFiles;
867 } 871 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/src/summary/prelinker_test.dart ('k') | pkg/analyzer/test/src/summary/resynthesize_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698