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 4470e51bc6ae1abde3ab918cfe87ebd080e38719..c82a6fb1cdf649a97de09693e966520c6dba03f1 100644 |
--- a/sdk/lib/_internal/pub/lib/src/package_graph.dart |
+++ b/sdk/lib/_internal/pub/lib/src/package_graph.dart |
@@ -4,6 +4,7 @@ |
library pub.package_graph; |
+import 'barback/transformer_cache.dart'; |
import 'entrypoint.dart'; |
import 'lock_file.dart'; |
import 'package.dart'; |
@@ -28,8 +29,26 @@ class PackageGraph { |
/// A map of transitive dependencies for each package. |
Map<String, Set<Package>> _transitiveDependencies; |
+ /// The transformer cache, if it's been loaded. |
+ TransformerCache _transformerCache; |
+ |
PackageGraph(this.entrypoint, this.lockFile, this.packages); |
+ /// Loads the transformer cache for this graph. |
+ /// |
+ /// This may only be called if [entrypoint] represents a physical package. |
+ /// This may modify the cache. |
+ TransformerCache loadTransformerCache() { |
+ if (_transformerCache == null) { |
+ if (entrypoint.root.dir == null) { |
+ throw new StateError("Can't load the transformer cache for virtual " |
+ "entrypoint ${entrypoint.root.name}."); |
+ } |
+ _transformerCache = new TransformerCache.load(this); |
+ } |
+ return _transformerCache; |
+ } |
+ |
/// Returns all transitive dependencies of [package]. |
/// |
/// For the entrypoint this returns all packages in [packages], which includes |