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

Unified Diff: pkg/analyzer/lib/src/summary/package_bundle_reader.dart

Issue 2226093002: Record information about a summary's dependencies in the summary itself. (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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/lib/src/summary/idl.dart ('k') | pkg/analyzer/lib/src/summary/summarize_elements.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/summary/package_bundle_reader.dart
diff --git a/pkg/analyzer/lib/src/summary/package_bundle_reader.dart b/pkg/analyzer/lib/src/summary/package_bundle_reader.dart
index 062ce82466032020f5e85ac5978e60a079f4c9d2..f56557ea236aba0f1e2ab75bb28f4c65032adbfe 100644
--- a/pkg/analyzer/lib/src/summary/package_bundle_reader.dart
+++ b/pkg/analyzer/lib/src/summary/package_bundle_reader.dart
@@ -10,6 +10,7 @@ import 'package:analyzer/src/generated/resolver.dart';
import 'package:analyzer/src/generated/source.dart';
import 'package:analyzer/src/generated/source_io.dart';
import 'package:analyzer/src/generated/utilities_dart.dart';
+import 'package:analyzer/src/summary/format.dart';
import 'package:analyzer/src/summary/idl.dart';
import 'package:analyzer/src/summary/resynthesize.dart';
import 'package:analyzer/src/task/dart.dart';
@@ -273,6 +274,15 @@ class SummaryDataStore {
final List<PackageBundle> bundles = <PackageBundle>[];
/**
+ * List of dependency information for the package bundles in this
+ * [SummaryDataStore], in a form that is ready to store in a newly generated.
scheglov 2016/08/09 02:39:44 Extra '.' at the end.
Paul Berry 2016/08/09 16:30:30 Fixed.
+ * summary. Computing this information has nonzero cost, so it is only
+ * recorded if the [SummaryDataStore] is constructed with the argument
+ * `recordDependencies`. Otherwise `null`.
+ */
+ final List<PackageDependencyInfoBuilder> dependencies;
+
+ /**
* Map from the URI of a compilation unit to the unlinked summary of that
* compilation unit.
*/
@@ -288,7 +298,16 @@ class SummaryDataStore {
*/
final Map<String, String> uriToSummaryPath = <String, String>{};
- SummaryDataStore(Iterable<String> summaryPaths) {
+ /**
+ * Create a [SummaryDataStore] and populate it with the summaries in
+ * [summaryPaths]. If [recordDependencyInfo] is `true`, record
+ * [PackageDependencyInfo] for each summary, for later access via
+ * [dependencies].
+ */
+ SummaryDataStore(Iterable<String> summaryPaths,
+ {bool recordDependencyInfo: false})
+ : dependencies =
+ recordDependencyInfo ? <PackageDependencyInfoBuilder>[] : null {
summaryPaths.forEach(_fillMaps);
}
@@ -297,6 +316,29 @@ class SummaryDataStore {
*/
void addBundle(String path, PackageBundle bundle) {
bundles.add(bundle);
+ if (dependencies != null) {
+ Set<String> includedPackageNames = new Set<String>();
+ bool includesDartUris = false;
+ bool includesFileUris = false;
+ for (String uriString in bundle.unlinkedUnitUris) {
+ Uri uri = FastUri.parse(uriString);
+ String scheme = uri.scheme;
+ if (scheme == 'package') {
+ List<String> pathSegments = uri.pathSegments;
+ includedPackageNames.add(pathSegments.isEmpty ? '' : pathSegments[0]);
+ } else if (scheme == 'file') {
+ includesFileUris = true;
+ } else if (scheme == 'dart') {
+ includesDartUris = true;
+ }
+ }
+ dependencies.add(new PackageDependencyInfoBuilder(
+ includedPackageNames: includedPackageNames.toList()..sort(),
+ includesDartUris: includesDartUris,
+ includesFileUris: includesFileUris,
+ apiSignature: bundle.apiSignature,
+ summaryPath: path));
+ }
for (int i = 0; i < bundle.unlinkedUnitUris.length; i++) {
String uri = bundle.unlinkedUnitUris[i];
uriToSummaryPath[uri] = path;
« no previous file with comments | « pkg/analyzer/lib/src/summary/idl.dart ('k') | pkg/analyzer/lib/src/summary/summarize_elements.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698