Index: sdk/lib/_internal/pub/lib/src/package_graph.dart |
diff --git a/sdk/lib/_internal/pub/lib/src/package_graph.dart b/sdk/lib/_internal/pub/lib/src/package_graph.dart |
index 687b7202ace05cbed9dd68757723106d6a4213fb..634eb5ce5918cbda59e756ed339b564406472cb8 100644 |
--- a/sdk/lib/_internal/pub/lib/src/package_graph.dart |
+++ b/sdk/lib/_internal/pub/lib/src/package_graph.dart |
@@ -18,4 +18,22 @@ class PackageGraph { |
final Map<String, Package> packages; |
PackageGraph(this.entrypoint, this.packages); |
+ |
+ /// Returns the set of transitive dependencies of the package named |
+ /// [packageName]. |
+ Set<Package> transitiveDependencies(String packageName) { |
+ var seen = new Set<Package>(); |
+ traverse(Package package) { |
+ if (seen.contains(package)) return; |
+ seen.add(package); |
+ for (var dep in package.dependencies) { |
+ traverse(packages[dep.name]); |
+ } |
+ } |
+ |
+ var package = packages[packageName]; |
+ traverse(package); |
+ seen.remove(package); |
+ return seen; |
+ } |
} |