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

Side by Side Diff: pkg/barback/lib/src/package_graph.dart

Issue 22265002: Support cross-package transforms in barback. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes. 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/barback/lib/src/build_result.dart ('k') | pkg/barback/lib/src/phase.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library barback.package_graph; 5 library barback.package_graph;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:stack_trace/stack_trace.dart'; 9 import 'package:stack_trace/stack_trace.dart';
10 10
11 import 'asset.dart'; 11 import 'asset.dart';
12 import 'asset_cascade.dart'; 12 import 'asset_cascade.dart';
13 import 'asset_id.dart'; 13 import 'asset_id.dart';
14 import 'asset_node.dart';
15 import 'build_result.dart';
14 import 'errors.dart'; 16 import 'errors.dart';
15 import 'package_provider.dart'; 17 import 'package_provider.dart';
16 import 'utils.dart'; 18 import 'utils.dart';
17 19
18 /// The collection of [AssetCascade]s for an entire application. 20 /// The collection of [AssetCascade]s for an entire application.
19 /// 21 ///
20 /// This tracks each package's [AssetCascade] and routes asset requests between 22 /// This tracks each package's [AssetCascade] and routes asset requests between
21 /// them. 23 /// them.
22 class PackageGraph { 24 class PackageGraph {
23 /// The provider that exposes asset and package information. 25 /// The provider that exposes asset and package information.
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 // Include all build errors for all cascades. If no cascades have 75 // Include all build errors for all cascades. If no cascades have
74 // errors, the result will automatically be considered a success. 76 // errors, the result will automatically be considered a success.
75 _resultsController.add(new BuildResult(flatten( 77 _resultsController.add(new BuildResult(flatten(
76 _cascadeResults.values.map((result) => result.errors)))); 78 _cascadeResults.values.map((result) => result.errors))));
77 }, onError: _resultsController.addError); 79 }, onError: _resultsController.addError);
78 } 80 }
79 81
80 _errors = mergeStreams(_cascades.values.map((cascade) => cascade.errors)); 82 _errors = mergeStreams(_cascades.values.map((cascade) => cascade.errors));
81 } 83 }
82 84
83 /// Gets the asset identified by [id]. 85 /// Gets the asset node identified by [id].
84 /// 86 ///
85 /// If [id] is for a generated or transformed asset, this will wait until 87 /// If [id] is for a generated or transformed asset, this will wait until it
86 /// it has been created and return it. If the asset cannot be found, throws 88 /// has been created and return it. If the asset cannot be found, returns
87 /// [AssetNotFoundException]. 89 /// null.
88 Future<Asset> getAssetById(AssetId id) { 90 Future<AssetNode> getAssetNode(AssetId id) {
89 var cascade = _cascades[id.package]; 91 var cascade = _cascades[id.package];
90 if (cascade != null) return cascade.getAssetById(id); 92 if (cascade != null) return cascade.getAssetNode(id);
91 return new Future.error( 93 return new Future.value(null);
92 new AssetNotFoundException(id),
93 new Trace.current().vmTrace);
94 } 94 }
95 95
96 /// Adds [sources] to the graph's known set of source assets. 96 /// Adds [sources] to the graph's known set of source assets.
97 /// 97 ///
98 /// Begins applying any transforms that can consume any of the sources. If a 98 /// Begins applying any transforms that can consume any of the sources. If a
99 /// given source is already known, it is considered modified and all 99 /// given source is already known, it is considered modified and all
100 /// transforms that use it will be re-applied. 100 /// transforms that use it will be re-applied.
101 void updateSources(Iterable<AssetId> sources) { 101 void updateSources(Iterable<AssetId> sources) {
102 groupBy(sources, (id) => id.package).forEach((package, ids) { 102 groupBy(sources, (id) => id.package).forEach((package, ids) {
103 var cascade = _cascades[package]; 103 var cascade = _cascades[package];
104 if (cascade == null) throw new ArgumentError("Unknown package $package."); 104 if (cascade == null) throw new ArgumentError("Unknown package $package.");
105 _cascadeResults[package] = null; 105 _cascadeResults[package] = null;
106 cascade.updateSources(ids); 106 cascade.updateSources(ids);
107 }); 107 });
108 } 108 }
109 109
110 /// Removes [removed] from the graph's known set of source assets. 110 /// Removes [removed] from the graph's known set of source assets.
111 void removeSources(Iterable<AssetId> sources) { 111 void removeSources(Iterable<AssetId> sources) {
112 groupBy(sources, (id) => id.package).forEach((package, ids) { 112 groupBy(sources, (id) => id.package).forEach((package, ids) {
113 var cascade = _cascades[package]; 113 var cascade = _cascades[package];
114 if (cascade == null) throw new ArgumentError("Unknown package $package."); 114 if (cascade == null) throw new ArgumentError("Unknown package $package.");
115 _cascadeResults[package] = null; 115 _cascadeResults[package] = null;
116 cascade.removeSources(ids); 116 cascade.removeSources(ids);
117 }); 117 });
118 } 118 }
119 } 119 }
OLDNEW
« no previous file with comments | « pkg/barback/lib/src/build_result.dart ('k') | pkg/barback/lib/src/phase.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698