| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |