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

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

Issue 2996783002: Don't record dependencies in SummaryDataStore. (Closed)
Patch Set: Created 3 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
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/summary/summarize_elements.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;
11 import 'package:analyzer/src/generated/source.dart'; 11 import 'package:analyzer/src/generated/source.dart';
12 import 'package:analyzer/src/generated/source_io.dart'; 12 import 'package:analyzer/src/generated/source_io.dart';
13 import 'package:analyzer/src/generated/utilities_dart.dart'; 13 import 'package:analyzer/src/generated/utilities_dart.dart';
14 import 'package:analyzer/src/summary/format.dart';
15 import 'package:analyzer/src/summary/idl.dart'; 14 import 'package:analyzer/src/summary/idl.dart';
16 import 'package:analyzer/src/summary/resynthesize.dart'; 15 import 'package:analyzer/src/summary/resynthesize.dart';
17 import 'package:analyzer/src/task/dart.dart'; 16 import 'package:analyzer/src/task/dart.dart';
18 import 'package:analyzer/task/dart.dart'; 17 import 'package:analyzer/task/dart.dart';
19 import 'package:analyzer/task/general.dart'; 18 import 'package:analyzer/task/general.dart';
20 import 'package:analyzer/task/model.dart'; 19 import 'package:analyzer/task/model.dart';
21 import 'package:front_end/src/base/source.dart'; 20 import 'package:front_end/src/base/source.dart';
22 21
23 /** 22 /**
24 * A [ConflictingSummaryException] indicates that two different summaries 23 * A [ConflictingSummaryException] indicates that two different summaries
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 * summary package bundles. It contains maps which can be used to find linked 361 * summary package bundles. It contains maps which can be used to find linked
363 * and unlinked summaries by URI. 362 * and unlinked summaries by URI.
364 */ 363 */
365 class SummaryDataStore { 364 class SummaryDataStore {
366 /** 365 /**
367 * List of all [PackageBundle]s. 366 * List of all [PackageBundle]s.
368 */ 367 */
369 final List<PackageBundle> bundles = <PackageBundle>[]; 368 final List<PackageBundle> bundles = <PackageBundle>[];
370 369
371 /** 370 /**
372 * List of dependency information for the package bundles in this
373 * [SummaryDataStore], in a form that is ready to store in a newly generated
374 * summary. Computing this information has nonzero cost, so it is only
375 * recorded if the [SummaryDataStore] is constructed with the argument
376 * `recordDependencies`. Otherwise `null`.
377 */
378 final List<PackageDependencyInfoBuilder> dependencies;
379
380 /**
381 * Map from the URI of a compilation unit to the unlinked summary of that 371 * Map from the URI of a compilation unit to the unlinked summary of that
382 * compilation unit. 372 * compilation unit.
383 */ 373 */
384 final Map<String, UnlinkedUnit> unlinkedMap = <String, UnlinkedUnit>{}; 374 final Map<String, UnlinkedUnit> unlinkedMap = <String, UnlinkedUnit>{};
385 375
386 /** 376 /**
387 * Map from the URI of a library to the linked summary of that library. 377 * Map from the URI of a library to the linked summary of that library.
388 */ 378 */
389 final Map<String, LinkedLibrary> linkedMap = <String, LinkedLibrary>{}; 379 final Map<String, LinkedLibrary> linkedMap = <String, LinkedLibrary>{};
390 380
391 /** 381 /**
392 * Map from the URI of a library to the summary path that contained it. 382 * Map from the URI of a library to the summary path that contained it.
393 */ 383 */
394 final Map<String, String> uriToSummaryPath = <String, String>{}; 384 final Map<String, String> uriToSummaryPath = <String, String>{};
395 385
396 /** 386 /**
397 * List of summary paths. 387 * List of summary paths.
398 */ 388 */
399 final Iterable<String> _summaryPaths; 389 final Iterable<String> _summaryPaths;
400 390
401 /** 391 /**
402 * If true, do not accept multiple summaries that contain the same Dart uri. 392 * If true, do not accept multiple summaries that contain the same Dart uri.
403 */ 393 */
404 bool _disallowOverlappingSummaries; 394 bool _disallowOverlappingSummaries;
405 395
406 /** 396 /**
407 * Create a [SummaryDataStore] and populate it with the summaries in 397 * Create a [SummaryDataStore] and populate it with the summaries in
408 * [summaryPaths]. If [recordDependencyInfo] is `true`, record 398 * [summaryPaths].
409 * [PackageDependencyInfo] for each summary, for later access via
410 * [dependencies].
411 */ 399 */
412 SummaryDataStore(Iterable<String> summaryPaths, 400 SummaryDataStore(Iterable<String> summaryPaths,
413 {bool recordDependencyInfo: false, 401 {bool disallowOverlappingSummaries: false,
414 bool disallowOverlappingSummaries: false,
415 ResourceProvider resourceProvider}) 402 ResourceProvider resourceProvider})
416 : _summaryPaths = summaryPaths, 403 : _summaryPaths = summaryPaths,
417 _disallowOverlappingSummaries = disallowOverlappingSummaries, 404 _disallowOverlappingSummaries = disallowOverlappingSummaries {
418 dependencies =
419 recordDependencyInfo ? <PackageDependencyInfoBuilder>[] : null {
420 summaryPaths.forEach((String path) => _fillMaps(path, resourceProvider)); 405 summaryPaths.forEach((String path) => _fillMaps(path, resourceProvider));
421 } 406 }
422 407
423 /** 408 /**
424 * Add the given [bundle] loaded from the file with the given [path]. 409 * Add the given [bundle] loaded from the file with the given [path].
425 */ 410 */
426 void addBundle(String path, PackageBundle bundle) { 411 void addBundle(String path, PackageBundle bundle) {
427 bundles.add(bundle); 412 bundles.add(bundle);
428 if (dependencies != null) {
429 Set<String> includedPackageNames = new Set<String>();
430 bool includesDartUris = false;
431 bool includesFileUris = false;
432 for (String uriString in bundle.unlinkedUnitUris) {
433 Uri uri = Uri.parse(uriString);
434 String scheme = uri.scheme;
435 if (scheme == 'package') {
436 List<String> pathSegments = uri.pathSegments;
437 includedPackageNames.add(pathSegments.isEmpty ? '' : pathSegments[0]);
438 } else if (scheme == 'file') {
439 includesFileUris = true;
440 } else if (scheme == 'dart') {
441 includesDartUris = true;
442 }
443 }
444 dependencies.add(new PackageDependencyInfoBuilder(
445 includedPackageNames: includedPackageNames.toList()..sort(),
446 includesDartUris: includesDartUris,
447 includesFileUris: includesFileUris,
448 apiSignature: bundle.apiSignature,
449 summaryPath: path));
450 }
451 for (int i = 0; i < bundle.unlinkedUnitUris.length; i++) { 413 for (int i = 0; i < bundle.unlinkedUnitUris.length; i++) {
452 String uri = bundle.unlinkedUnitUris[i]; 414 String uri = bundle.unlinkedUnitUris[i];
453 if (_disallowOverlappingSummaries && 415 if (_disallowOverlappingSummaries &&
454 uriToSummaryPath.containsKey(uri) && 416 uriToSummaryPath.containsKey(uri) &&
455 (uriToSummaryPath[uri] != path)) { 417 (uriToSummaryPath[uri] != path)) {
456 throw new ConflictingSummaryException( 418 throw new ConflictingSummaryException(
457 _summaryPaths, uri, uriToSummaryPath[uri], path); 419 _summaryPaths, uri, uriToSummaryPath[uri], path);
458 } 420 }
459 uriToSummaryPath[uri] = path; 421 uriToSummaryPath[uri] = path;
460 addUnlinkedUnit(uri, bundle.unlinkedUnits[i]); 422 addUnlinkedUnit(uri, bundle.unlinkedUnits[i]);
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 var file = resourceProvider.getFile(path); 488 var file = resourceProvider.getFile(path);
527 buffer = file.readAsBytesSync(); 489 buffer = file.readAsBytesSync();
528 } else { 490 } else {
529 io.File file = new io.File(path); 491 io.File file = new io.File(path);
530 buffer = file.readAsBytesSync(); 492 buffer = file.readAsBytesSync();
531 } 493 }
532 PackageBundle bundle = new PackageBundle.fromBuffer(buffer); 494 PackageBundle bundle = new PackageBundle.fromBuffer(buffer);
533 addBundle(path, bundle); 495 addBundle(path, bundle);
534 } 496 }
535 } 497 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/summary/summarize_elements.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698