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

Side by Side Diff: pkg/barback/lib/src/graph/phase.dart

Issue 299833003: Expose aggregate transformers in barback. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: code review Created 6 years, 6 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
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.graph.phase; 5 library barback.graph.phase;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import '../asset/asset_id.dart'; 9 import '../asset/asset_id.dart';
10 import '../asset/asset_node.dart'; 10 import '../asset/asset_node.dart';
11 import '../asset/asset_node_set.dart'; 11 import '../asset/asset_node_set.dart';
12 import '../errors.dart'; 12 import '../errors.dart';
13 import '../log.dart'; 13 import '../log.dart';
14 import '../transformer/aggregate_transformer.dart';
14 import '../transformer/transformer.dart'; 15 import '../transformer/transformer.dart';
15 import '../transformer/transformer_group.dart'; 16 import '../transformer/transformer_group.dart';
16 import '../utils.dart'; 17 import '../utils.dart';
17 import '../utils/multiset.dart'; 18 import '../utils/multiset.dart';
18 import 'asset_cascade.dart'; 19 import 'asset_cascade.dart';
19 import 'group_runner.dart'; 20 import 'group_runner.dart';
20 import 'node_status.dart'; 21 import 'node_status.dart';
21 import 'node_streams.dart'; 22 import 'node_streams.dart';
22 import 'phase_forwarder.dart'; 23 import 'phase_forwarder.dart';
23 import 'phase_output.dart'; 24 import 'phase_output.dart';
(...skipping 24 matching lines...) Expand all
48 /// The groups for this phase. 49 /// The groups for this phase.
49 final _groups = new Map<TransformerGroup, GroupRunner>(); 50 final _groups = new Map<TransformerGroup, GroupRunner>();
50 51
51 /// The inputs for this phase. 52 /// The inputs for this phase.
52 /// 53 ///
53 /// For the first phase, these will be the source assets. For all other 54 /// For the first phase, these will be the source assets. For all other
54 /// phases, they will be the outputs from the previous phase. 55 /// phases, they will be the outputs from the previous phase.
55 final _inputs = new AssetNodeSet(); 56 final _inputs = new AssetNodeSet();
56 57
57 /// The transformer classifiers for this phase. 58 /// The transformer classifiers for this phase.
58 final _classifiers = new Map<Transformer, TransformerClassifier>(); 59 ///
60 /// The keys can be either [Transformer]s or [AggregateTransformer]s.
61 final _classifiers = new Map<dynamic, TransformerClassifier>();
59 62
60 /// The forwarders for this phase. 63 /// The forwarders for this phase.
61 final _forwarders = new Map<AssetId, PhaseForwarder>(); 64 final _forwarders = new Map<AssetId, PhaseForwarder>();
62 65
63 /// The outputs for this phase. 66 /// The outputs for this phase.
64 final _outputs = new Map<AssetId, PhaseOutput>(); 67 final _outputs = new Map<AssetId, PhaseOutput>();
65 68
66 /// The set of all [AssetNode.origin] properties of the input assets for this 69 /// The set of all [AssetNode.origin] properties of the input assets for this
67 /// phase. 70 /// phase.
68 /// 71 ///
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 // Otherwise, store a completer for the asset node. If it's generated in 229 // Otherwise, store a completer for the asset node. If it's generated in
227 // the future, we'll complete this completer. 230 // the future, we'll complete this completer.
228 var completer = _pendingOutputRequests.putIfAbsent(id, 231 var completer = _pendingOutputRequests.putIfAbsent(id,
229 () => new Completer.sync()); 232 () => new Completer.sync());
230 return completer.future; 233 return completer.future;
231 }); 234 });
232 } 235 }
233 236
234 /// Set this phase's transformers to [transformers]. 237 /// Set this phase's transformers to [transformers].
235 void updateTransformers(Iterable transformers) { 238 void updateTransformers(Iterable transformers) {
236 var newTransformers = transformers.where((op) => op is Transformer) 239 var newTransformers = transformers
240 .where((op) => op is Transformer || op is AggregateTransformer)
237 .toSet(); 241 .toSet();
238 var oldTransformers = _classifiers.keys.toSet(); 242 var oldTransformers = _classifiers.keys.toSet();
239 for (var removed in oldTransformers.difference(newTransformers)) { 243 for (var removed in oldTransformers.difference(newTransformers)) {
240 _classifiers.remove(removed).remove(); 244 _classifiers.remove(removed).remove();
241 } 245 }
242 246
243 for (var transformer in newTransformers.difference(oldTransformers)) { 247 for (var transformer in newTransformers.difference(oldTransformers)) {
244 var classifier = new TransformerClassifier( 248 var classifier = new TransformerClassifier(
245 this, transformer, "$_location.$_index"); 249 this, transformer, "$_location.$_index");
246 _classifiers[transformer] = classifier; 250 _classifiers[transformer] = classifier;
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 assert(asset.state.isDirty); 382 assert(asset.state.isDirty);
379 asset.force(); 383 asset.force();
380 asset.whenStateChanges().then((state) { 384 asset.whenStateChanges().then((state) {
381 if (state.isRemoved) return getOutput(asset.id); 385 if (state.isRemoved) return getOutput(asset.id);
382 return asset; 386 return asset;
383 }).then(request.complete).catchError(request.completeError); 387 }).then(request.complete).catchError(request.completeError);
384 } 388 }
385 389
386 String toString() => "phase $_location.$_index"; 390 String toString() => "phase $_location.$_index";
387 } 391 }
OLDNEW
« no previous file with comments | « pkg/barback/lib/src/graph/package_graph.dart ('k') | pkg/barback/lib/src/graph/transform_node.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698