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

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

Issue 2700843002: Use absolute URIs for LinkedDependency.uri/parts. (Closed)
Patch Set: Created 3 years, 10 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/error/error.dart'; 9 import 'package:analyzer/error/error.dart';
10 import 'package:analyzer/src/dart/element/element.dart'; 10 import 'package:analyzer/src/dart/element/element.dart';
(...skipping 871 matching lines...) Expand 10 before | Expand all | Expand 10 after
882 } 882 }
883 883
884 void _serializeLibrary(Source librarySource) { 884 void _serializeLibrary(Source librarySource) {
885 if (librarySource == null || librarySource.isInSystemLibrary) { 885 if (librarySource == null || librarySource.isInSystemLibrary) {
886 return; 886 return;
887 } 887 }
888 if (!serializedSources.add(librarySource)) { 888 if (!serializedSources.add(librarySource)) {
889 return; 889 return;
890 } 890 }
891 891
892 Source resolveRelativeUri(String relativeUri) { 892 UnlinkedUnit getPart(String absoluteUri) {
893 Source resolvedSource = 893 Source source = context.sourceFactory.forUri(absoluteUri);
894 context.sourceFactory.resolveUri(librarySource, relativeUri); 894 return _getUnlinkedUnit(source);
895 if (resolvedSource == null && !allowMissingFiles) {
896 throw new StateError('Could not resolve $relativeUri in the context of '
897 '$librarySource (${librarySource.runtimeType})');
898 }
899 return resolvedSource;
900 }
901
902 UnlinkedUnit getPart(String relativeUri) {
903 return _getUnlinkedUnit(resolveRelativeUri(relativeUri));
904 } 895 }
905 896
906 UnlinkedPublicNamespace getImport(String relativeUri) { 897 UnlinkedPublicNamespace getImport(String relativeUri) {
907 return getPart(relativeUri)?.publicNamespace; 898 return getPart(relativeUri)?.publicNamespace;
908 } 899 }
909 900
910 UnlinkedUnit definingUnit = _getUnlinkedUnit(librarySource); 901 UnlinkedUnit definingUnit = _getUnlinkedUnit(librarySource);
911 if (definingUnit != null) { 902 if (definingUnit != null) {
912 LinkedLibraryBuilder linkedLibrary = prelink( 903 LinkedLibraryBuilder linkedLibrary = prelink(librarySource.uri.toString(),
913 definingUnit, getPart, getImport, context.declaredVariables.get); 904 definingUnit, getPart, getImport, context.declaredVariables.get);
914 linkedLibrary.dependencies.skip(1).forEach((LinkedDependency d) { 905 linkedLibrary.dependencies.skip(1).forEach((LinkedDependency d) {
915 _serializeLibrary(resolveRelativeUri(d.uri)); 906 Source source = context.sourceFactory.forUri(d.uri);
907 _serializeLibrary(source);
916 }); 908 });
917 } 909 }
918 } 910 }
919 } 911 }
920 912
921 /** 913 /**
922 * Interface that [_AstResynthesizeTestMixin] requires of classes it's mixed 914 * Interface that [_AstResynthesizeTestMixin] requires of classes it's mixed
923 * into. We can't place the getter below into [_AstResynthesizeTestMixin] 915 * into. We can't place the getter below into [_AstResynthesizeTestMixin]
924 * directly, because then it would be overriding a field at the site where the 916 * directly, because then it would be overriding a field at the site where the
925 * mixin is instantiated. 917 * mixin is instantiated.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
958 } 950 }
959 951
960 @override 952 @override
961 DartSdk createDartSdk() => AbstractContextTest.SHARED_MOCK_SDK; 953 DartSdk createDartSdk() => AbstractContextTest.SHARED_MOCK_SDK;
962 954
963 @override 955 @override
964 TestSummaryResynthesizer encodeDecodeLibrarySource(Source source) { 956 TestSummaryResynthesizer encodeDecodeLibrarySource(Source source) {
965 return _encodeLibrary(source); 957 return _encodeLibrary(source);
966 } 958 }
967 } 959 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698