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

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

Issue 2652823002: Use single InputPackagesResultProvider, without SdkSummaryResultProvider. (Closed)
Patch Set: Fixes for analyzer_cli. 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) 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 test.src.serialization.elements_test; 5 library test.src.serialization.elements_test;
6 6
7 import 'package:analyzer/dart/ast/ast.dart'; 7 import 'package:analyzer/dart/ast/ast.dart';
8 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; 8 import 'package:analyzer/dart/ast/standard_resolution_map.dart';
9 import 'package:analyzer/dart/constant/value.dart'; 9 import 'package:analyzer/dart/constant/value.dart';
10 import 'package:analyzer/dart/element/element.dart'; 10 import 'package:analyzer/dart/element/element.dart';
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 } 139 }
140 140
141 /** 141 /**
142 * Verify that the [resynthesizer] didn't do any unnecessary work when 142 * Verify that the [resynthesizer] didn't do any unnecessary work when
143 * resynthesizing [library]. 143 * resynthesizing [library].
144 */ 144 */
145 void checkMinimalResynthesisWork( 145 void checkMinimalResynthesisWork(
146 TestSummaryResynthesizer resynthesizer, LibraryElement library) { 146 TestSummaryResynthesizer resynthesizer, LibraryElement library) {
147 // Check that no other summaries needed to be resynthesized to resynthesize 147 // Check that no other summaries needed to be resynthesized to resynthesize
148 // the library element. 148 // the library element.
149 expect(resynthesizer.resynthesisCount, 1); 149 expect(resynthesizer.resynthesisCount, 3);
150 // Check that the only linked summary consulted was that for [uri]. 150 // Check that the only linked summary consulted was that for [uri].
151 expect(resynthesizer.linkedSummariesRequested, hasLength(1)); 151 expect(resynthesizer.linkedSummariesRequested, hasLength(1));
152 expect(resynthesizer.linkedSummariesRequested.first, 152 expect(resynthesizer.linkedSummariesRequested.first,
153 library.source.uri.toString()); 153 library.source.uri.toString());
154 // Check that the only unlinked summaries consulted were those for the 154 // Check that the only unlinked summaries consulted were those for the
155 // library in question. 155 // library in question.
156 Set<String> expectedCompilationUnitUris = library.units 156 Set<String> expectedCompilationUnitUris = library.units
157 .map((CompilationUnitElement unit) => unit.source.uri.toString()) 157 .map((CompilationUnitElement unit) => unit.source.uri.toString())
158 .toSet(); 158 .toSet();
159 for (String requestedUri in resynthesizer.unlinkedSummariesRequested) { 159 for (String requestedUri in resynthesizer.unlinkedSummariesRequested) {
(...skipping 4721 matching lines...) Expand 10 before | Expand all | Expand 10 after
4881 * element from the resynthesized summary. 4881 * element from the resynthesized summary.
4882 */ 4882 */
4883 Element validateGetElement(String text, Element original) { 4883 Element validateGetElement(String text, Element original) {
4884 SummaryResynthesizer resynthesizer = 4884 SummaryResynthesizer resynthesizer =
4885 encodeDecodeLibrarySource(original.library.source); 4885 encodeDecodeLibrarySource(original.library.source);
4886 ElementLocationImpl location = original.location; 4886 ElementLocationImpl location = original.location;
4887 Element result = resynthesizer.getElement(location); 4887 Element result = resynthesizer.getElement(location);
4888 checkMinimalResynthesisWork(resynthesizer, original.library); 4888 checkMinimalResynthesisWork(resynthesizer, original.library);
4889 // Check that no other summaries needed to be resynthesized to resynthesize 4889 // Check that no other summaries needed to be resynthesized to resynthesize
4890 // the library element. 4890 // the library element.
4891 expect(resynthesizer.resynthesisCount, 1); 4891 expect(resynthesizer.resynthesisCount, 3);
4892 expect(result.location, location); 4892 expect(result.location, location);
4893 return result; 4893 return result;
4894 } 4894 }
4895 } 4895 }
4896 4896
4897 class TestSummaryResynthesizer extends SummaryResynthesizer { 4897 class TestSummaryResynthesizer extends SummaryResynthesizer {
4898 final Map<String, UnlinkedUnit> unlinkedSummaries; 4898 final Map<String, UnlinkedUnit> unlinkedSummaries;
4899 final Map<String, LinkedLibrary> linkedSummaries; 4899 final Map<String, LinkedLibrary> linkedSummaries;
4900 final bool allowMissingFiles; 4900 final bool allowMissingFiles;
4901 4901
4902 /** 4902 /**
4903 * The set of uris for which unlinked summaries have been requested using 4903 * The set of uris for which unlinked summaries have been requested using
4904 * [getUnlinkedSummary]. 4904 * [getUnlinkedSummary].
4905 */ 4905 */
4906 final Set<String> unlinkedSummariesRequested = new Set<String>(); 4906 final Set<String> unlinkedSummariesRequested = new Set<String>();
4907 4907
4908 /** 4908 /**
4909 * The set of uris for which linked summaries have been requested using 4909 * The set of uris for which linked summaries have been requested using
4910 * [getLinkedSummary]. 4910 * [getLinkedSummary].
4911 */ 4911 */
4912 final Set<String> linkedSummariesRequested = new Set<String>(); 4912 final Set<String> linkedSummariesRequested = new Set<String>();
4913 4913
4914 TestSummaryResynthesizer(SummaryResynthesizer parent, AnalysisContext context, 4914 TestSummaryResynthesizer(SummaryResynthesizer parent, AnalysisContext context,
4915 this.unlinkedSummaries, this.linkedSummaries, this.allowMissingFiles) 4915 this.unlinkedSummaries, this.linkedSummaries, this.allowMissingFiles)
4916 : super(parent, context, context.typeProvider, context.sourceFactory, 4916 : super(parent, context, context.sourceFactory,
4917 context.analysisOptions.strongMode); 4917 context.analysisOptions.strongMode) {
4918 // Clear after resynthesizing TypeProvider in super().
4919 unlinkedSummariesRequested.clear();
4920 linkedSummariesRequested.clear();
4921 }
4918 4922
4919 @override 4923 @override
4920 LinkedLibrary getLinkedSummary(String uri) { 4924 LinkedLibrary getLinkedSummary(String uri) {
4921 linkedSummariesRequested.add(uri); 4925 linkedSummariesRequested.add(uri);
4922 LinkedLibrary serializedLibrary = linkedSummaries[uri]; 4926 LinkedLibrary serializedLibrary = linkedSummaries[uri];
4923 if (serializedLibrary == null && !allowMissingFiles) { 4927 if (serializedLibrary == null && !allowMissingFiles) {
4924 fail('Unexpectedly tried to get linked summary for $uri'); 4928 fail('Unexpectedly tried to get linked summary for $uri');
4925 } 4929 }
4926 return serializedLibrary; 4930 return serializedLibrary;
4927 } 4931 }
4928 4932
4929 @override 4933 @override
4930 UnlinkedUnit getUnlinkedSummary(String uri) { 4934 UnlinkedUnit getUnlinkedSummary(String uri) {
4931 unlinkedSummariesRequested.add(uri); 4935 unlinkedSummariesRequested.add(uri);
4932 UnlinkedUnit serializedUnit = unlinkedSummaries[uri]; 4936 UnlinkedUnit serializedUnit = unlinkedSummaries[uri];
4933 if (serializedUnit == null && !allowMissingFiles) { 4937 if (serializedUnit == null && !allowMissingFiles) {
4934 fail('Unexpectedly tried to get unlinked summary for $uri'); 4938 fail('Unexpectedly tried to get unlinked summary for $uri');
4935 } 4939 }
4936 return serializedUnit; 4940 return serializedUnit;
4937 } 4941 }
4938 4942
4939 @override 4943 @override
4940 bool hasLibrarySummary(String uri) { 4944 bool hasLibrarySummary(String uri) {
4941 return true; 4945 return true;
4942 } 4946 }
4943 } 4947 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698