| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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.transformer_classifier; | 5 library barback.graph.transformer_classifier; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import '../asset/asset_forwarder.dart'; | 9 import '../asset/asset_forwarder.dart'; |
| 10 import '../asset/asset_node.dart'; | 10 import '../asset/asset_node.dart'; |
| 11 import '../errors.dart'; | 11 import '../errors.dart'; |
| 12 import '../log.dart'; | 12 import '../log.dart'; |
| 13 import '../transformer/aggregate_transformer.dart'; | 13 import '../transformer/aggregate_transformer.dart'; |
| 14 import '../transformer/wrapping_aggregate_transformer.dart'; | 14 import '../transformer/wrapping_aggregate_transformer.dart'; |
| 15 import '../utils.dart'; | |
| 16 import 'node_status.dart'; | 15 import 'node_status.dart'; |
| 17 import 'node_streams.dart'; | 16 import 'node_streams.dart'; |
| 18 import 'phase.dart'; | 17 import 'phase.dart'; |
| 19 import 'transform_node.dart'; | 18 import 'transform_node.dart'; |
| 20 | 19 |
| 21 /// A class for classifying the primary inputs for a transformer according to | 20 /// A class for classifying the primary inputs for a transformer according to |
| 22 /// its [AggregateTransformer.classifyPrimary] method. | 21 /// its [AggregateTransformer.classifyPrimary] method. |
| 23 /// | 22 /// |
| 24 /// This is also used for non-aggregate transformers; they're modeled as | 23 /// This is also used for non-aggregate transformers; they're modeled as |
| 25 /// aggregate transformers that return the primary path if `isPrimary` is true | 24 /// aggregate transformers that return the primary path if `isPrimary` is true |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 _transforms.values.map((transform) => transform.status)); | 66 _transforms.values.map((transform) => transform.status)); |
| 68 } | 67 } |
| 69 | 68 |
| 70 TransformerClassifier(this.phase, transformer, this._location) | 69 TransformerClassifier(this.phase, transformer, this._location) |
| 71 : transformer = transformer is AggregateTransformer ? | 70 : transformer = transformer is AggregateTransformer ? |
| 72 transformer : new WrappingAggregateTransformer(transformer); | 71 transformer : new WrappingAggregateTransformer(transformer); |
| 73 | 72 |
| 74 /// Adds a new asset as an input for this transformer. | 73 /// Adds a new asset as an input for this transformer. |
| 75 void addInput(AssetNode input) { | 74 void addInput(AssetNode input) { |
| 76 _activeClassifications++; | 75 _activeClassifications++; |
| 77 syncFuture(() => transformer.classifyPrimary(input.id)).catchError( | 76 new Future.sync(() => transformer.classifyPrimary(input.id)) |
| 78 (error, stackTrace) { | 77 .catchError((error, stackTrace) { |
| 79 if (input.state.isRemoved) return null; | 78 if (input.state.isRemoved) return null; |
| 80 | 79 |
| 81 // Catch all transformer errors and pipe them to the results stream. This | 80 // Catch all transformer errors and pipe them to the results stream. This |
| 82 // is so a broken transformer doesn't take down the whole graph. | 81 // is so a broken transformer doesn't take down the whole graph. |
| 83 var info = new TransformInfo(transformer, input.id); | 82 var info = new TransformInfo(transformer, input.id); |
| 84 if (error is! AssetNotFoundException) { | 83 if (error is! AssetNotFoundException) { |
| 85 error = new TransformerException(info, error, stackTrace); | 84 error = new TransformerException(info, error, stackTrace); |
| 86 } else { | 85 } else { |
| 87 error = new MissingInputException(info, error.id); | 86 error = new MissingInputException(info, error.id); |
| 88 } | 87 } |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 | 137 |
| 139 /// Force all deferred transforms to begin producing concrete assets. | 138 /// Force all deferred transforms to begin producing concrete assets. |
| 140 void forceAllTransforms() { | 139 void forceAllTransforms() { |
| 141 for (var transform in _transforms.values) { | 140 for (var transform in _transforms.values) { |
| 142 transform.force(); | 141 transform.force(); |
| 143 } | 142 } |
| 144 } | 143 } |
| 145 | 144 |
| 146 String toString() => "classifier in $_location for $transformer"; | 145 String toString() => "classifier in $_location for $transformer"; |
| 147 } | 146 } |
| OLD | NEW |