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

Side by Side Diff: pkg/analyzer/test/src/summary/summarize_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.summarize_ast_test; 5 library analyzer.test.src.summary.summarize_ast_test;
6 6
7 import 'package:analyzer/analyzer.dart'; 7 import 'package:analyzer/analyzer.dart';
8 import 'package:analyzer/dart/ast/ast.dart'; 8 import 'package:analyzer/dart/ast/ast.dart';
9 import 'package:analyzer/dart/ast/token.dart'; 9 import 'package:analyzer/dart/ast/token.dart';
10 import 'package:analyzer/error/listener.dart'; 10 import 'package:analyzer/error/listener.dart';
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 @override 146 @override
147 bool get skipFullyLinkedData => false; 147 bool get skipFullyLinkedData => false;
148 148
149 @override 149 @override
150 bool get skipNonConstInitializers => false; 150 bool get skipNonConstInitializers => false;
151 151
152 @override 152 @override
153 void serializeLibraryText(String text, {bool allowErrors: false}) { 153 void serializeLibraryText(String text, {bool allowErrors: false}) {
154 Map<String, UnlinkedUnitBuilder> uriToUnit = this._filesToLink.uriToUnit; 154 Map<String, UnlinkedUnitBuilder> uriToUnit = this._filesToLink.uriToUnit;
155 LinkerInputs linkerInputs = createLinkerInputs(text); 155 LinkerInputs linkerInputs = createLinkerInputs(text);
156 linked = link(linkerInputs.linkedLibraries, linkerInputs.getDependency, 156 linked = link(
157 linkerInputs.getUnit, strongMode)[linkerInputs.testDartUri.toString()]; 157 linkerInputs.linkedLibraries,
158 linkerInputs.getDependency,
159 linkerInputs.getUnit,
160 (name) => null,
161 strongMode)[linkerInputs.testDartUri.toString()];
158 expect(linked, isNotNull); 162 expect(linked, isNotNull);
159 validateLinkedLibrary(linked); 163 validateLinkedLibrary(linked);
160 unlinkedUnits = <UnlinkedUnit>[linkerInputs.unlinkedDefiningUnit]; 164 unlinkedUnits = <UnlinkedUnit>[linkerInputs.unlinkedDefiningUnit];
161 for (String relativeUri 165 for (String relativeUri
162 in linkerInputs.unlinkedDefiningUnit.publicNamespace.parts) { 166 in linkerInputs.unlinkedDefiningUnit.publicNamespace.parts) {
163 UnlinkedUnit unit = uriToUnit[ 167 UnlinkedUnit unit = uriToUnit[
164 resolveRelativeUri(linkerInputs.testDartUri, Uri.parse(relativeUri)) 168 resolveRelativeUri(linkerInputs.testDartUri, Uri.parse(relativeUri))
165 .toString()]; 169 .toString()];
166 if (unit == null) { 170 if (unit == null) {
167 if (!allowMissingFiles) { 171 if (!allowMissingFiles) {
(...skipping 28 matching lines...) Expand all
196 LinkerInputs( 200 LinkerInputs(
197 this._allowMissingFiles, 201 this._allowMissingFiles,
198 this._uriToUnit, 202 this._uriToUnit,
199 this.testDartUri, 203 this.testDartUri,
200 this.unlinkedDefiningUnit, 204 this.unlinkedDefiningUnit,
201 this._dependentLinkedLibraries, 205 this._dependentLinkedLibraries,
202 this._dependentUnlinkedUnits); 206 this._dependentUnlinkedUnits);
203 207
204 Set<String> get linkedLibraries => _uriToUnit.keys.toSet(); 208 Set<String> get linkedLibraries => _uriToUnit.keys.toSet();
205 209
210 String getDeclaredVariable(String name) {
211 return null;
212 }
213
206 LinkedLibrary getDependency(String absoluteUri) { 214 LinkedLibrary getDependency(String absoluteUri) {
207 Map<String, LinkedLibrary> sdkLibraries = 215 Map<String, LinkedLibrary> sdkLibraries =
208 SerializedMockSdk.instance.uriToLinkedLibrary; 216 SerializedMockSdk.instance.uriToLinkedLibrary;
209 LinkedLibrary linkedLibrary = 217 LinkedLibrary linkedLibrary =
210 sdkLibraries[absoluteUri] ?? _dependentLinkedLibraries[absoluteUri]; 218 sdkLibraries[absoluteUri] ?? _dependentLinkedLibraries[absoluteUri];
211 if (linkedLibrary == null && !_allowMissingFiles) { 219 if (linkedLibrary == null && !_allowMissingFiles) {
212 Set<String> librariesAvailable = sdkLibraries.keys.toSet(); 220 Set<String> librariesAvailable = sdkLibraries.keys.toSet();
213 librariesAvailable.addAll(_dependentLinkedLibraries.keys); 221 librariesAvailable.addAll(_dependentLinkedLibraries.keys);
214 fail('Linker unexpectedly requested LinkedLibrary for "$absoluteUri".' 222 fail('Linker unexpectedly requested LinkedLibrary for "$absoluteUri".'
215 ' Libraries available: ${librariesAvailable.toList()}'); 223 ' Libraries available: ${librariesAvailable.toList()}');
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 */ 300 */
293 PackageBundleBuilder createPackageBundle(String text, 301 PackageBundleBuilder createPackageBundle(String text,
294 {String path: '/test.dart', String uri}) { 302 {String path: '/test.dart', String uri}) {
295 PackageBundleAssembler assembler = new PackageBundleAssembler(); 303 PackageBundleAssembler assembler = new PackageBundleAssembler();
296 assembler.recordDependencies(_filesToLink.summaryDataStore); 304 assembler.recordDependencies(_filesToLink.summaryDataStore);
297 LinkerInputs linkerInputs = createLinkerInputs(text, path: path, uri: uri); 305 LinkerInputs linkerInputs = createLinkerInputs(text, path: path, uri: uri);
298 Map<String, LinkedLibraryBuilder> linkedLibraries = link( 306 Map<String, LinkedLibraryBuilder> linkedLibraries = link(
299 linkerInputs.linkedLibraries, 307 linkerInputs.linkedLibraries,
300 linkerInputs.getDependency, 308 linkerInputs.getDependency,
301 linkerInputs.getUnit, 309 linkerInputs.getUnit,
310 linkerInputs.getDeclaredVariable,
302 true); 311 true);
303 linkedLibraries.forEach(assembler.addLinkedLibrary); 312 linkedLibraries.forEach(assembler.addLinkedLibrary);
304 linkerInputs._uriToUnit.forEach((String uri, UnlinkedUnit unit) { 313 linkerInputs._uriToUnit.forEach((String uri, UnlinkedUnit unit) {
305 // Note: it doesn't matter what we store for the hash because it isn't 314 // Note: it doesn't matter what we store for the hash because it isn't
306 // used in these tests. 315 // used in these tests.
307 assembler.addUnlinkedUnitWithHash(uri, unit, 'HASH'); 316 assembler.addUnlinkedUnitWithHash(uri, unit, 'HASH');
308 }); 317 });
309 return assembler.assemble(); 318 return assembler.assemble();
310 } 319 }
311 320
(...skipping 21 matching lines...) Expand all
333 * passed to [addNamedSource]. 342 * passed to [addNamedSource].
334 */ 343 */
335 Map<String, UnlinkedUnitBuilder> uriToUnit = <String, UnlinkedUnitBuilder>{}; 344 Map<String, UnlinkedUnitBuilder> uriToUnit = <String, UnlinkedUnitBuilder>{};
336 345
337 /** 346 /**
338 * Information about summaries to be included in the link process. 347 * Information about summaries to be included in the link process.
339 */ 348 */
340 SummaryDataStore summaryDataStore = 349 SummaryDataStore summaryDataStore =
341 new SummaryDataStore([], recordDependencyInfo: true); 350 new SummaryDataStore([], recordDependencyInfo: true);
342 } 351 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/src/summary/resynthesize_test.dart ('k') | pkg/analyzer/test/src/summary/summary_common.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698