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

Unified Diff: pkg/barback/lib/src/asset_cascade.dart

Issue 22265002: Support cross-package transforms in barback. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Remove a duplicated test. Created 7 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/barback/lib/src/asset_cascade.dart
diff --git a/pkg/barback/lib/src/asset_cascade.dart b/pkg/barback/lib/src/asset_cascade.dart
index 7818f7037f0fffa1302f03845c7145d1977b9079..b7042b19eea5cf442feb31ad27e664f631ffd61e 100644
--- a/pkg/barback/lib/src/asset_cascade.dart
+++ b/pkg/barback/lib/src/asset_cascade.dart
@@ -7,11 +7,10 @@ library barback.asset_cascade;
import 'dart:async';
import 'dart:collection';
-import 'package:stack_trace/stack_trace.dart';
-
import 'asset.dart';
import 'asset_id.dart';
import 'asset_node.dart';
+import 'build_result.dart';
import 'cancelable_future.dart';
import 'errors.dart';
import 'change_batch.dart';
@@ -24,7 +23,7 @@ import 'utils.dart';
///
/// This keeps track of which [Transformer]s are applied to which assets, and
/// re-runs those transformers when their dependencies change. The transformed
-/// assets are accessible via [getAssetById].
+/// asset nodes are accessible via [getAssetNode].
///
/// A cascade consists of one or more [Phases], each of which has one or more
/// [Transformer]s that run in parallel, potentially on the same inputs. The
@@ -37,7 +36,7 @@ class AssetCascade {
/// The [PackageGraph] that tracks all [AssetCascade]s for all dependencies of
/// the current app.
- final PackageGraph _graph;
+ final PackageGraph graph;
/// The controllers for the [AssetNode]s that provide information about this
/// cascade's package's source assets.
@@ -89,7 +88,7 @@ class AssetCascade {
/// It loads source assets within [package] using [provider] and then uses
/// [transformerPhases] to generate output files from them.
//TODO(rnystrom): Better way of specifying transformers and their ordering.
- AssetCascade(this._graph, this.package,
+ AssetCascade(this.graph, this.package,
Iterable<Iterable<Transformer>> transformerPhases) {
// Flatten the phases to a list so we can traverse backwards to wire up
// each phase to its next.
@@ -116,7 +115,7 @@ class AssetCascade {
/// If [id] is for a generated or transformed asset, this will wait until
/// it has been created and return it. If the asset cannot be found, throws
/// [AssetNotFoundException].
- Future<Asset> getAssetById(AssetId id) {
+ Future<AssetNode> getAssetNode(AssetId id) {
assert(id.package == package);
// TODO(rnystrom): Waiting for the entire build to complete is unnecessary
@@ -131,12 +130,12 @@ class AssetCascade {
var node = _getAssetNode(id);
// If the requested asset is available, we can just return it.
- if (node != null) return node.asset;
+ if (node != null) return node;
// If there's a build running, that build might generate the asset, so we
// wait for it to complete and then try again.
if (_processDone != null) {
- return _processDone.then((_) => getAssetById(id));
+ return _processDone.then((_) => getAssetNode(id));
}
// If the asset hasn't been built and nothing is building now, the asset
@@ -183,7 +182,7 @@ class AssetCascade {
if (_loadingSources.containsKey(id)) _loadingSources[id].cancel();
_loadingSources[id] =
- new CancelableFuture<Asset>(_graph.provider.getAsset(id));
+ new CancelableFuture<Asset>(graph.provider.getAsset(id));
_loadingSources[id].whenComplete(() {
_loadingSources.remove(id);
}).then((asset) {
@@ -272,43 +271,3 @@ class AssetCascade {
});
}
}
-
-/// An event indicating that the cascade has finished building all assets.
-///
-/// A build can end either in success or failure. If there were no errors during
-/// the build, it's considered to be a success; any errors render it a failure,
-/// although individual assets may still have built successfully.
-class BuildResult {
- /// All errors that occurred during the build.
- final List errors;
-
- /// `true` if the build succeeded.
- bool get succeeded => errors.isEmpty;
-
- BuildResult(Iterable errors)
- : errors = errors.toList();
-
- /// Creates a build result indicating a successful build.
- ///
- /// This equivalent to a build result with no errors.
- BuildResult.success()
- : this([]);
-
- String toString() {
- if (succeeded) return "success";
-
- return "errors:\n" + errors.map((error) {
- var stackTrace = getAttachedStackTrace(error);
- if (stackTrace != null) stackTrace = new Trace.from(stackTrace);
-
- var msg = new StringBuffer();
- msg.write(prefixLines(error.toString()));
- if (stackTrace != null) {
- msg.write("\n\n");
- msg.write("Stack trace:\n");
- msg.write(prefixLines(stackTrace.toString()));
- }
- return msg.toString();
- }).join("\n\n");
- }
-}

Powered by Google App Engine
This is Rietveld 408576698