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

Side by Side Diff: pkg/analyzer/lib/src/summary/package_bundle_reader.dart

Issue 2829493002: Make conflicting summary check configurable (Closed)
Patch Set: Created 3 years, 8 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
« no previous file with comments | « no previous file | pkg/analyzer/test/src/summary/package_bundle_reader_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 import 'dart:io' as io; 1 import 'dart:io' as io;
2 import 'dart:math' show min; 2 import 'dart:math' show min;
3 3
4 import 'package:analyzer/dart/element/element.dart'; 4 import 'package:analyzer/dart/element/element.dart';
5 import 'package:analyzer/file_system/file_system.dart'; 5 import 'package:analyzer/file_system/file_system.dart';
6 import 'package:analyzer/src/context/cache.dart'; 6 import 'package:analyzer/src/context/cache.dart';
7 import 'package:analyzer/src/context/context.dart'; 7 import 'package:analyzer/src/context/context.dart';
8 import 'package:analyzer/src/dart/element/element.dart'; 8 import 'package:analyzer/src/dart/element/element.dart';
9 import 'package:analyzer/src/generated/engine.dart'; 9 import 'package:analyzer/src/generated/engine.dart';
10 import 'package:analyzer/src/generated/resolver.dart' show TypeProvider; 10 import 'package:analyzer/src/generated/resolver.dart' show TypeProvider;
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 * Map from the URI of a library to the summary path that contained it. 391 * Map from the URI of a library to the summary path that contained it.
392 */ 392 */
393 final Map<String, String> uriToSummaryPath = <String, String>{}; 393 final Map<String, String> uriToSummaryPath = <String, String>{};
394 394
395 /** 395 /**
396 * List of summary paths. 396 * List of summary paths.
397 */ 397 */
398 final Iterable<String> _summaryPaths; 398 final Iterable<String> _summaryPaths;
399 399
400 /** 400 /**
401 * If true, do not accept multiple summaries that contain the same Dart uri.
402 */
403 bool _disallowOverlappingSummaries;
404
405 /**
401 * Create a [SummaryDataStore] and populate it with the summaries in 406 * Create a [SummaryDataStore] and populate it with the summaries in
402 * [summaryPaths]. If [recordDependencyInfo] is `true`, record 407 * [summaryPaths]. If [recordDependencyInfo] is `true`, record
403 * [PackageDependencyInfo] for each summary, for later access via 408 * [PackageDependencyInfo] for each summary, for later access via
404 * [dependencies]. 409 * [dependencies].
405 */ 410 */
406 SummaryDataStore(Iterable<String> summaryPaths, 411 SummaryDataStore(Iterable<String> summaryPaths,
407 {bool recordDependencyInfo: false, ResourceProvider resourceProvider}) 412 {bool recordDependencyInfo: false,
413 bool disallowOverlappingSummaries: false,
414 ResourceProvider resourceProvider})
408 : _summaryPaths = summaryPaths, 415 : _summaryPaths = summaryPaths,
416 _disallowOverlappingSummaries = disallowOverlappingSummaries,
409 dependencies = 417 dependencies =
410 recordDependencyInfo ? <PackageDependencyInfoBuilder>[] : null { 418 recordDependencyInfo ? <PackageDependencyInfoBuilder>[] : null {
411 summaryPaths.forEach((String path) => _fillMaps(path, resourceProvider)); 419 summaryPaths.forEach((String path) => _fillMaps(path, resourceProvider));
412 } 420 }
413 421
414 /** 422 /**
415 * Add the given [bundle] loaded from the file with the given [path]. 423 * Add the given [bundle] loaded from the file with the given [path].
416 */ 424 */
417 void addBundle(String path, PackageBundle bundle) { 425 void addBundle(String path, PackageBundle bundle) {
418 bundles.add(bundle); 426 bundles.add(bundle);
(...skipping 15 matching lines...) Expand all
434 } 442 }
435 dependencies.add(new PackageDependencyInfoBuilder( 443 dependencies.add(new PackageDependencyInfoBuilder(
436 includedPackageNames: includedPackageNames.toList()..sort(), 444 includedPackageNames: includedPackageNames.toList()..sort(),
437 includesDartUris: includesDartUris, 445 includesDartUris: includesDartUris,
438 includesFileUris: includesFileUris, 446 includesFileUris: includesFileUris,
439 apiSignature: bundle.apiSignature, 447 apiSignature: bundle.apiSignature,
440 summaryPath: path)); 448 summaryPath: path));
441 } 449 }
442 for (int i = 0; i < bundle.unlinkedUnitUris.length; i++) { 450 for (int i = 0; i < bundle.unlinkedUnitUris.length; i++) {
443 String uri = bundle.unlinkedUnitUris[i]; 451 String uri = bundle.unlinkedUnitUris[i];
444 if (uriToSummaryPath.containsKey(uri) && 452 if (_disallowOverlappingSummaries &&
453 uriToSummaryPath.containsKey(uri) &&
445 (uriToSummaryPath[uri] != path)) { 454 (uriToSummaryPath[uri] != path)) {
446 throw new ConflictingSummaryException( 455 throw new ConflictingSummaryException(
447 _summaryPaths, uri, uriToSummaryPath[uri], path); 456 _summaryPaths, uri, uriToSummaryPath[uri], path);
448 } 457 }
449 uriToSummaryPath[uri] = path; 458 uriToSummaryPath[uri] = path;
450 addUnlinkedUnit(uri, bundle.unlinkedUnits[i]); 459 addUnlinkedUnit(uri, bundle.unlinkedUnits[i]);
451 } 460 }
452 for (int i = 0; i < bundle.linkedLibraryUris.length; i++) { 461 for (int i = 0; i < bundle.linkedLibraryUris.length; i++) {
453 String uri = bundle.linkedLibraryUris[i]; 462 String uri = bundle.linkedLibraryUris[i];
454 addLinkedLibrary(uri, bundle.linkedLibraries[i]); 463 addLinkedLibrary(uri, bundle.linkedLibraries[i]);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 var file = resourceProvider.getFile(path); 509 var file = resourceProvider.getFile(path);
501 buffer = file.readAsBytesSync(); 510 buffer = file.readAsBytesSync();
502 } else { 511 } else {
503 io.File file = new io.File(path); 512 io.File file = new io.File(path);
504 buffer = file.readAsBytesSync(); 513 buffer = file.readAsBytesSync();
505 } 514 }
506 PackageBundle bundle = new PackageBundle.fromBuffer(buffer); 515 PackageBundle bundle = new PackageBundle.fromBuffer(buffer);
507 addBundle(path, bundle); 516 addBundle(path, bundle);
508 } 517 }
509 } 518 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/test/src/summary/package_bundle_reader_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698