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

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

Issue 2242883003: Fix resolveRelativeUri() to handle correctly empty contained Uri(s). (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 4 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/src/dart/scanner/reader.dart'; 10 import 'package:analyzer/src/dart/scanner/reader.dart';
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 */ 312 */
313 Source addNamedSource(String filePath, String contents) { 313 Source addNamedSource(String filePath, String contents) {
314 CompilationUnit unit = _parseText(contents); 314 CompilationUnit unit = _parseText(contents);
315 UnlinkedUnitBuilder unlinkedUnit = serializeAstUnlinked(unit); 315 UnlinkedUnitBuilder unlinkedUnit = serializeAstUnlinked(unit);
316 _filesToLink.uriToUnit[absUri(filePath)] = unlinkedUnit; 316 _filesToLink.uriToUnit[absUri(filePath)] = unlinkedUnit;
317 // Tests using SummaryLinkerTest don't actually need the returned 317 // Tests using SummaryLinkerTest don't actually need the returned
318 // Source, so we can safely return `null`. 318 // Source, so we can safely return `null`.
319 return null; 319 return null;
320 } 320 }
321 321
322 LinkerInputs createLinkerInputs(String text, {String path: '/test.dart'}) { 322 LinkerInputs createLinkerInputs(String text, {String path: '/test.dart', Strin g uri}) {
323 Uri testDartUri = Uri.parse(absUri(path)); 323 uri ??= absUri(path);
324 Uri testDartUri = Uri.parse(uri);
324 CompilationUnit unit = _parseText(text); 325 CompilationUnit unit = _parseText(text);
325 UnlinkedUnitBuilder unlinkedDefiningUnit = serializeAstUnlinked(unit); 326 UnlinkedUnitBuilder unlinkedDefiningUnit = serializeAstUnlinked(unit);
326 _filesToLink.uriToUnit[testDartUri.toString()] = unlinkedDefiningUnit; 327 _filesToLink.uriToUnit[testDartUri.toString()] = unlinkedDefiningUnit;
327 LinkerInputs linkerInputs = new LinkerInputs( 328 LinkerInputs linkerInputs = new LinkerInputs(
328 allowMissingFiles, 329 allowMissingFiles,
329 _filesToLink.uriToUnit, 330 _filesToLink.uriToUnit,
330 testDartUri, 331 testDartUri,
331 unlinkedDefiningUnit, 332 unlinkedDefiningUnit,
332 _filesToLink.summaryDataStore.linkedMap, 333 _filesToLink.summaryDataStore.linkedMap,
333 _filesToLink.summaryDataStore.unlinkedMap); 334 _filesToLink.summaryDataStore.unlinkedMap);
334 // Reset _filesToLink in case the test needs to start a new package bundle. 335 // Reset _filesToLink in case the test needs to start a new package bundle.
335 _filesToLink = new _FilesToLink(); 336 _filesToLink = new _FilesToLink();
336 return linkerInputs; 337 return linkerInputs;
337 } 338 }
338 339
339 /** 340 /**
340 * Link together the given file, along with any other files passed to 341 * Link together the given file, along with any other files passed to
341 * [addNamedSource], to form a package bundle. Reset the state of the buffers 342 * [addNamedSource], to form a package bundle. Reset the state of the buffers
342 * accumulated by [addNamedSource] and [addBundle] so that further bundles 343 * accumulated by [addNamedSource] and [addBundle] so that further bundles
343 * can be created. 344 * can be created.
344 */ 345 */
345 PackageBundleBuilder createPackageBundle(String text, 346 PackageBundleBuilder createPackageBundle(String text,
346 {String path: '/test.dart'}) { 347 {String path: '/test.dart', String uri}) {
347 PackageBundleAssembler assembler = new PackageBundleAssembler(); 348 PackageBundleAssembler assembler = new PackageBundleAssembler();
348 assembler.recordDependencies(_filesToLink.summaryDataStore); 349 assembler.recordDependencies(_filesToLink.summaryDataStore);
349 LinkerInputs linkerInputs = createLinkerInputs(text, path: path); 350 LinkerInputs linkerInputs = createLinkerInputs(text, path: path, uri: uri);
350 Map<String, LinkedLibraryBuilder> linkedLibraries = link( 351 Map<String, LinkedLibraryBuilder> linkedLibraries = link(
351 linkerInputs.linkedLibraries, 352 linkerInputs.linkedLibraries,
352 linkerInputs.getDependency, 353 linkerInputs.getDependency,
353 linkerInputs.getUnit, 354 linkerInputs.getUnit,
354 true); 355 true);
355 linkedLibraries.forEach(assembler.addLinkedLibrary); 356 linkedLibraries.forEach(assembler.addLinkedLibrary);
356 linkerInputs._uriToUnit.forEach((String uri, UnlinkedUnit unit) { 357 linkerInputs._uriToUnit.forEach((String uri, UnlinkedUnit unit) {
357 // Note: it doesn't matter what we store for the hash because it isn't 358 // Note: it doesn't matter what we store for the hash because it isn't
358 // used in these tests. 359 // used in these tests.
359 assembler.addUnlinkedUnitWithHash(uri, unit, 'HASH'); 360 assembler.addUnlinkedUnitWithHash(uri, unit, 'HASH');
(...skipping 25 matching lines...) Expand all
385 * passed to [addNamedSource]. 386 * passed to [addNamedSource].
386 */ 387 */
387 Map<String, UnlinkedUnitBuilder> uriToUnit = <String, UnlinkedUnitBuilder>{}; 388 Map<String, UnlinkedUnitBuilder> uriToUnit = <String, UnlinkedUnitBuilder>{};
388 389
389 /** 390 /**
390 * Information about summaries to be included in the link process. 391 * Information about summaries to be included in the link process.
391 */ 392 */
392 SummaryDataStore summaryDataStore = 393 SummaryDataStore summaryDataStore =
393 new SummaryDataStore([], recordDependencyInfo: true); 394 new SummaryDataStore([], recordDependencyInfo: true);
394 } 395 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698