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

Unified Diff: pkg/analyzer/lib/src/summary/format.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
Index: pkg/analyzer/lib/src/summary/format.dart
diff --git a/pkg/analyzer/lib/src/summary/format.dart b/pkg/analyzer/lib/src/summary/format.dart
index be1de5469aec441fe7a762e6561fa2617fc1a872..626f4431234a2f108dd3e8aec202d43c8582f3b1 100644
--- a/pkg/analyzer/lib/src/summary/format.dart
+++ b/pkg/analyzer/lib/src/summary/format.dart
@@ -2099,6 +2099,7 @@ abstract class _LinkedUnitMixin implements idl.LinkedUnit {
class PackageBundleBuilder extends Object with _PackageBundleMixin implements idl.PackageBundle {
String _apiSignature;
+ List<PackageDependencyInfoBuilder> _dependencies;
List<LinkedLibraryBuilder> _linkedLibraries;
List<String> _linkedLibraryUris;
int _majorVersion;
@@ -2120,6 +2121,16 @@ class PackageBundleBuilder extends Object with _PackageBundleMixin implements id
}
@override
+ List<PackageDependencyInfoBuilder> get dependencies => _dependencies ??= <PackageDependencyInfoBuilder>[];
+
+ /**
+ * Information about the packages this package depends on, if known.
+ */
+ void set dependencies(List<PackageDependencyInfoBuilder> _value) {
+ _dependencies = _value;
+ }
+
+ @override
List<LinkedLibraryBuilder> get linkedLibraries => _linkedLibraries ??= <LinkedLibraryBuilder>[];
/**
@@ -2195,8 +2206,9 @@ class PackageBundleBuilder extends Object with _PackageBundleMixin implements id
_unlinkedUnitUris = _value;
}
- PackageBundleBuilder({String apiSignature, List<LinkedLibraryBuilder> linkedLibraries, List<String> linkedLibraryUris, int majorVersion, int minorVersion, List<String> unlinkedUnitHashes, List<UnlinkedUnitBuilder> unlinkedUnits, List<String> unlinkedUnitUris})
+ PackageBundleBuilder({String apiSignature, List<PackageDependencyInfoBuilder> dependencies, List<LinkedLibraryBuilder> linkedLibraries, List<String> linkedLibraryUris, int majorVersion, int minorVersion, List<String> unlinkedUnitHashes, List<UnlinkedUnitBuilder> unlinkedUnits, List<String> unlinkedUnitUris})
: _apiSignature = apiSignature,
+ _dependencies = dependencies,
_linkedLibraries = linkedLibraries,
_linkedLibraryUris = linkedLibraryUris,
_majorVersion = majorVersion,
@@ -2209,6 +2221,7 @@ class PackageBundleBuilder extends Object with _PackageBundleMixin implements id
* Flush [informative] data recursively.
*/
void flushInformative() {
+ _dependencies = null;
_linkedLibraries?.forEach((b) => b.flushInformative());
_unlinkedUnitHashes = null;
_unlinkedUnits?.forEach((b) => b.flushInformative());
@@ -2262,6 +2275,7 @@ class PackageBundleBuilder extends Object with _PackageBundleMixin implements id
fb.Offset finish(fb.Builder fbBuilder) {
fb.Offset offset_apiSignature;
+ fb.Offset offset_dependencies;
fb.Offset offset_linkedLibraries;
fb.Offset offset_linkedLibraryUris;
fb.Offset offset_unlinkedUnitHashes;
@@ -2270,6 +2284,9 @@ class PackageBundleBuilder extends Object with _PackageBundleMixin implements id
if (_apiSignature != null) {
offset_apiSignature = fbBuilder.writeString(_apiSignature);
}
+ if (!(_dependencies == null || _dependencies.isEmpty)) {
+ offset_dependencies = fbBuilder.writeList(_dependencies.map((b) => b.finish(fbBuilder)).toList());
+ }
if (!(_linkedLibraries == null || _linkedLibraries.isEmpty)) {
offset_linkedLibraries = fbBuilder.writeList(_linkedLibraries.map((b) => b.finish(fbBuilder)).toList());
}
@@ -2289,6 +2306,9 @@ class PackageBundleBuilder extends Object with _PackageBundleMixin implements id
if (offset_apiSignature != null) {
fbBuilder.addOffset(7, offset_apiSignature);
}
+ if (offset_dependencies != null) {
+ fbBuilder.addOffset(8, offset_dependencies);
+ }
if (offset_linkedLibraries != null) {
fbBuilder.addOffset(0, offset_linkedLibraries);
}
@@ -2333,6 +2353,7 @@ class _PackageBundleImpl extends Object with _PackageBundleMixin implements idl.
_PackageBundleImpl(this._bc, this._bcOffset);
String _apiSignature;
+ List<idl.PackageDependencyInfo> _dependencies;
List<idl.LinkedLibrary> _linkedLibraries;
List<String> _linkedLibraryUris;
int _majorVersion;
@@ -2348,6 +2369,12 @@ class _PackageBundleImpl extends Object with _PackageBundleMixin implements idl.
}
@override
+ List<idl.PackageDependencyInfo> get dependencies {
+ _dependencies ??= const fb.ListReader<idl.PackageDependencyInfo>(const _PackageDependencyInfoReader()).vTableGet(_bc, _bcOffset, 8, const <idl.PackageDependencyInfo>[]);
+ return _dependencies;
+ }
+
+ @override
List<idl.LinkedLibrary> get linkedLibraries {
_linkedLibraries ??= const fb.ListReader<idl.LinkedLibrary>(const _LinkedLibraryReader()).vTableGet(_bc, _bcOffset, 0, const <idl.LinkedLibrary>[]);
return _linkedLibraries;
@@ -2395,6 +2422,7 @@ abstract class _PackageBundleMixin implements idl.PackageBundle {
Map<String, Object> toJson() {
Map<String, Object> _result = <String, Object>{};
if (apiSignature != '') _result["apiSignature"] = apiSignature;
+ if (dependencies.isNotEmpty) _result["dependencies"] = dependencies.map((_value) => _value.toJson()).toList();
if (linkedLibraries.isNotEmpty) _result["linkedLibraries"] = linkedLibraries.map((_value) => _value.toJson()).toList();
if (linkedLibraryUris.isNotEmpty) _result["linkedLibraryUris"] = linkedLibraryUris;
if (majorVersion != 0) _result["majorVersion"] = majorVersion;
@@ -2408,6 +2436,7 @@ abstract class _PackageBundleMixin implements idl.PackageBundle {
@override
Map<String, Object> toMap() => {
"apiSignature": apiSignature,
+ "dependencies": dependencies,
"linkedLibraries": linkedLibraries,
"linkedLibraryUris": linkedLibraryUris,
"majorVersion": majorVersion,
@@ -2421,6 +2450,212 @@ abstract class _PackageBundleMixin implements idl.PackageBundle {
String toString() => convert.JSON.encode(toJson());
}
+class PackageDependencyInfoBuilder extends Object with _PackageDependencyInfoMixin implements idl.PackageDependencyInfo {
+ String _apiSignature;
+ List<String> _includedPackageNames;
+ bool _includesDartUris;
+ bool _includesFileUris;
+ String _summaryPath;
+
+ @override
+ String get apiSignature => _apiSignature ??= '';
+
+ /**
+ * API signature of this dependency.
+ */
+ void set apiSignature(String _value) {
+ _apiSignature = _value;
+ }
+
+ @override
+ List<String> get includedPackageNames => _includedPackageNames ??= <String>[];
+
+ /**
+ * If this dependency summarizes any files whose URI takes the form
+ * "package:<package_name>/...", a list of all such package names, sorted
+ * lexicographically. Otherwise empty.
+ */
+ void set includedPackageNames(List<String> _value) {
+ _includedPackageNames = _value;
+ }
+
+ @override
+ bool get includesDartUris => _includesDartUris ??= false;
+
+ /**
+ * Indicates whether this dependency summarizes any files whose URI takes the
+ * form "dart:...".
+ */
+ void set includesDartUris(bool _value) {
+ _includesDartUris = _value;
+ }
+
+ @override
+ bool get includesFileUris => _includesFileUris ??= false;
+
+ /**
+ * Indicates whether this dependency summarizes any files whose URI takes the
+ * form "file:...".
+ */
+ void set includesFileUris(bool _value) {
+ _includesFileUris = _value;
+ }
+
+ @override
+ String get summaryPath => _summaryPath ??= '';
+
+ /**
+ * Relative path to the summary file for this dependency. This is intended as
+ * a hint to help the analysis server locate summaries of dependencies. We
+ * don't specify precisely what this path is relative to, but we expect it to
+ * be relative to a directory the analysis server can find (e.g. for projects
+ * built using Bazel, it would be relative to the "bazel-bin" directory).
+ *
+ * Absent if the path is not known.
+ */
+ void set summaryPath(String _value) {
+ _summaryPath = _value;
+ }
+
+ PackageDependencyInfoBuilder({String apiSignature, List<String> includedPackageNames, bool includesDartUris, bool includesFileUris, String summaryPath})
+ : _apiSignature = apiSignature,
+ _includedPackageNames = includedPackageNames,
+ _includesDartUris = includesDartUris,
+ _includesFileUris = includesFileUris,
+ _summaryPath = summaryPath;
+
+ /**
+ * Flush [informative] data recursively.
+ */
+ void flushInformative() {
+ }
+
+ /**
+ * Accumulate non-[informative] data into [signature].
+ */
+ void collectApiSignature(api_sig.ApiSignature signature) {
+ signature.addString(this._apiSignature ?? '');
+ signature.addString(this._summaryPath ?? '');
+ if (this._includedPackageNames == null) {
+ signature.addInt(0);
+ } else {
+ signature.addInt(this._includedPackageNames.length);
+ for (var x in this._includedPackageNames) {
+ signature.addString(x);
+ }
+ }
+ signature.addBool(this._includesFileUris == true);
+ signature.addBool(this._includesDartUris == true);
+ }
+
+ fb.Offset finish(fb.Builder fbBuilder) {
+ fb.Offset offset_apiSignature;
+ fb.Offset offset_includedPackageNames;
+ fb.Offset offset_summaryPath;
+ if (_apiSignature != null) {
+ offset_apiSignature = fbBuilder.writeString(_apiSignature);
+ }
+ if (!(_includedPackageNames == null || _includedPackageNames.isEmpty)) {
+ offset_includedPackageNames = fbBuilder.writeList(_includedPackageNames.map((b) => fbBuilder.writeString(b)).toList());
+ }
+ if (_summaryPath != null) {
+ offset_summaryPath = fbBuilder.writeString(_summaryPath);
+ }
+ fbBuilder.startTable();
+ if (offset_apiSignature != null) {
+ fbBuilder.addOffset(0, offset_apiSignature);
+ }
+ if (offset_includedPackageNames != null) {
+ fbBuilder.addOffset(2, offset_includedPackageNames);
+ }
+ if (_includesDartUris == true) {
+ fbBuilder.addBool(4, true);
+ }
+ if (_includesFileUris == true) {
+ fbBuilder.addBool(3, true);
+ }
+ if (offset_summaryPath != null) {
+ fbBuilder.addOffset(1, offset_summaryPath);
+ }
+ return fbBuilder.endTable();
+ }
+}
+
+class _PackageDependencyInfoReader extends fb.TableReader<_PackageDependencyInfoImpl> {
+ const _PackageDependencyInfoReader();
+
+ @override
+ _PackageDependencyInfoImpl createObject(fb.BufferContext bc, int offset) => new _PackageDependencyInfoImpl(bc, offset);
+}
+
+class _PackageDependencyInfoImpl extends Object with _PackageDependencyInfoMixin implements idl.PackageDependencyInfo {
+ final fb.BufferContext _bc;
+ final int _bcOffset;
+
+ _PackageDependencyInfoImpl(this._bc, this._bcOffset);
+
+ String _apiSignature;
+ List<String> _includedPackageNames;
+ bool _includesDartUris;
+ bool _includesFileUris;
+ String _summaryPath;
+
+ @override
+ String get apiSignature {
+ _apiSignature ??= const fb.StringReader().vTableGet(_bc, _bcOffset, 0, '');
+ return _apiSignature;
+ }
+
+ @override
+ List<String> get includedPackageNames {
+ _includedPackageNames ??= const fb.ListReader<String>(const fb.StringReader()).vTableGet(_bc, _bcOffset, 2, const <String>[]);
+ return _includedPackageNames;
+ }
+
+ @override
+ bool get includesDartUris {
+ _includesDartUris ??= const fb.BoolReader().vTableGet(_bc, _bcOffset, 4, false);
+ return _includesDartUris;
+ }
+
+ @override
+ bool get includesFileUris {
+ _includesFileUris ??= const fb.BoolReader().vTableGet(_bc, _bcOffset, 3, false);
+ return _includesFileUris;
+ }
+
+ @override
+ String get summaryPath {
+ _summaryPath ??= const fb.StringReader().vTableGet(_bc, _bcOffset, 1, '');
+ return _summaryPath;
+ }
+}
+
+abstract class _PackageDependencyInfoMixin implements idl.PackageDependencyInfo {
+ @override
+ Map<String, Object> toJson() {
+ Map<String, Object> _result = <String, Object>{};
+ if (apiSignature != '') _result["apiSignature"] = apiSignature;
+ if (includedPackageNames.isNotEmpty) _result["includedPackageNames"] = includedPackageNames;
+ if (includesDartUris != false) _result["includesDartUris"] = includesDartUris;
+ if (includesFileUris != false) _result["includesFileUris"] = includesFileUris;
+ if (summaryPath != '') _result["summaryPath"] = summaryPath;
+ return _result;
+ }
+
+ @override
+ Map<String, Object> toMap() => {
+ "apiSignature": apiSignature,
+ "includedPackageNames": includedPackageNames,
+ "includesDartUris": includesDartUris,
+ "includesFileUris": includesFileUris,
+ "summaryPath": summaryPath,
+ };
+
+ @override
+ String toString() => convert.JSON.encode(toJson());
+}
+
class PackageIndexBuilder extends Object with _PackageIndexMixin implements idl.PackageIndex {
List<idl.IndexSyntheticElementKind> _elementKinds;
List<int> _elementNameClassMemberIds;
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/summary/format.fbs » ('j') | pkg/analyzer/lib/src/summary/package_bundle_reader.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698