| OLD | NEW |
| 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.transform_node; | 5 library barback.transform_node; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'asset.dart'; | 9 import 'asset.dart'; |
| 10 import 'asset_id.dart'; | 10 import 'asset_id.dart'; |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 /// [AssetNotFoundException]. | 153 /// [AssetNotFoundException]. |
| 154 Future<Asset> getInput(AssetId id) { | 154 Future<Asset> getInput(AssetId id) { |
| 155 return phase.getInput(id).then((node) { | 155 return phase.getInput(id).then((node) { |
| 156 // Throw if the input isn't found. This ensures the transformer's apply | 156 // Throw if the input isn't found. This ensures the transformer's apply |
| 157 // is exited. We'll then catch this and report it through the proper | 157 // is exited. We'll then catch this and report it through the proper |
| 158 // results stream. | 158 // results stream. |
| 159 if (node == null) throw new MissingInputException(info, id); | 159 if (node == null) throw new MissingInputException(info, id); |
| 160 | 160 |
| 161 // If the asset node is found, wait until its contents are actually | 161 // If the asset node is found, wait until its contents are actually |
| 162 // available before we return them. | 162 // available before we return them. |
| 163 return node.whenAvailable.then((asset) { | 163 return node.whenAvailable((asset) { |
| 164 _inputSubscriptions.putIfAbsent(node.id, | 164 _inputSubscriptions.putIfAbsent(node.id, |
| 165 () => node.onStateChange.listen((_) => _dirty())); | 165 () => node.onStateChange.listen((_) => _dirty())); |
| 166 | 166 |
| 167 return asset; | 167 return asset; |
| 168 }).catchError((error) { | 168 }).catchError((error) { |
| 169 if (error is! AssetNotFoundException || error.id != id) throw error; | 169 if (error is! AssetNotFoundException || error.id != id) throw error; |
| 170 // If the node was removed before it could be loaded, treat it as though | 170 // If the node was removed before it could be loaded, treat it as though |
| 171 // it never existed and throw a MissingInputException. | 171 // it never existed and throw a MissingInputException. |
| 172 throw new MissingInputException(info, id); | 172 throw new MissingInputException(info, id); |
| 173 }); | 173 }); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 } | 211 } |
| 212 | 212 |
| 213 void _log(AssetId asset, LogLevel level, String message, Span span) { | 213 void _log(AssetId asset, LogLevel level, String message, Span span) { |
| 214 // If the log isn't already associated with an asset, use the primary. | 214 // If the log isn't already associated with an asset, use the primary. |
| 215 if (asset == null) asset = primary.id; | 215 if (asset == null) asset = primary.id; |
| 216 var info = new TransformInfo(transformer, primary.id); | 216 var info = new TransformInfo(transformer, primary.id); |
| 217 var entry = new LogEntry(info, asset, level, message, span); | 217 var entry = new LogEntry(info, asset, level, message, span); |
| 218 _onLogController.add(entry); | 218 _onLogController.add(entry); |
| 219 } | 219 } |
| 220 } | 220 } |
| OLD | NEW |