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

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

Issue 2615903003: Fix for resynthesizing libraries with invalid part URIs. (Closed)
Patch Set: Un-fail other tests. Created 3 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
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 814 matching lines...) Expand 10 before | Expand all | Expand 10 after
825 new Map<String, UnlinkedUnit>() 825 new Map<String, UnlinkedUnit>()
826 ..addAll(SerializedMockSdk.instance.uriToUnlinkedUnit) 826 ..addAll(SerializedMockSdk.instance.uriToUnlinkedUnit)
827 ..addAll(unlinkedSummaries), 827 ..addAll(unlinkedSummaries),
828 new Map<String, LinkedLibrary>() 828 new Map<String, LinkedLibrary>()
829 ..addAll(SerializedMockSdk.instance.uriToLinkedLibrary) 829 ..addAll(SerializedMockSdk.instance.uriToLinkedLibrary)
830 ..addAll(linkedSummaries), 830 ..addAll(linkedSummaries),
831 allowMissingFiles); 831 allowMissingFiles);
832 } 832 }
833 833
834 UnlinkedUnit _getUnlinkedUnit(Source source) { 834 UnlinkedUnit _getUnlinkedUnit(Source source) {
835 if (source == null) {
836 return new UnlinkedUnitBuilder();
837 }
838
835 String uriStr = source.uri.toString(); 839 String uriStr = source.uri.toString();
836 { 840 {
837 UnlinkedUnit unlinkedUnitInSdk = 841 UnlinkedUnit unlinkedUnitInSdk =
838 SerializedMockSdk.instance.uriToUnlinkedUnit[uriStr]; 842 SerializedMockSdk.instance.uriToUnlinkedUnit[uriStr];
839 if (unlinkedUnitInSdk != null) { 843 if (unlinkedUnitInSdk != null) {
840 return unlinkedUnitInSdk; 844 return unlinkedUnitInSdk;
841 } 845 }
842 } 846 }
843 return uriToUnit.putIfAbsent(uriStr, () { 847 return uriToUnit.putIfAbsent(uriStr, () {
844 int modificationTime = context.computeResult(source, MODIFICATION_TIME); 848 int modificationTime = context.computeResult(source, MODIFICATION_TIME);
(...skipping 21 matching lines...) Expand all
866 if (librarySource.isInSystemLibrary) { 870 if (librarySource.isInSystemLibrary) {
867 return; 871 return;
868 } 872 }
869 if (!serializedSources.add(librarySource)) { 873 if (!serializedSources.add(librarySource)) {
870 return; 874 return;
871 } 875 }
872 876
873 Source resolveRelativeUri(String relativeUri) { 877 Source resolveRelativeUri(String relativeUri) {
874 Source resolvedSource = 878 Source resolvedSource =
875 context.sourceFactory.resolveUri(librarySource, relativeUri); 879 context.sourceFactory.resolveUri(librarySource, relativeUri);
876 if (resolvedSource == null) { 880 if (resolvedSource == null && !allowMissingFiles) {
877 throw new StateError('Could not resolve $relativeUri in the context of ' 881 throw new StateError('Could not resolve $relativeUri in the context of '
878 '$librarySource (${librarySource.runtimeType})'); 882 '$librarySource (${librarySource.runtimeType})');
879 } 883 }
880 return resolvedSource; 884 return resolvedSource;
881 } 885 }
882 886
883 UnlinkedUnit getPart(String relativeUri) { 887 UnlinkedUnit getPart(String relativeUri) {
884 return _getUnlinkedUnit(resolveRelativeUri(relativeUri)); 888 return _getUnlinkedUnit(resolveRelativeUri(relativeUri));
885 } 889 }
886 890
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
939 } 943 }
940 944
941 @override 945 @override
942 DartSdk createDartSdk() => AbstractContextTest.SHARED_MOCK_SDK; 946 DartSdk createDartSdk() => AbstractContextTest.SHARED_MOCK_SDK;
943 947
944 @override 948 @override
945 TestSummaryResynthesizer encodeDecodeLibrarySource(Source source) { 949 TestSummaryResynthesizer encodeDecodeLibrarySource(Source source) {
946 return _encodeLibrary(source); 950 return _encodeLibrary(source);
947 } 951 }
948 } 952 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/summary/resynthesize.dart ('k') | pkg/analyzer/test/src/summary/resynthesize_common.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698