| 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.asset_cascade; | 5 library barback.asset_cascade; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 | 9 |
| 10 import 'asset.dart'; | 10 import 'asset.dart'; |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 | 114 |
| 115 /// Creates a new [AssetCascade]. | 115 /// Creates a new [AssetCascade]. |
| 116 /// | 116 /// |
| 117 /// It loads source assets within [package] using [provider]. | 117 /// It loads source assets within [package] using [provider]. |
| 118 AssetCascade(this.graph, this.package) { | 118 AssetCascade(this.graph, this.package) { |
| 119 _onDirtyPool.add(_onDirtyController.stream); | 119 _onDirtyPool.add(_onDirtyController.stream); |
| 120 _addPhase(new Phase(this, [])); | 120 _addPhase(new Phase(this, [])); |
| 121 | 121 |
| 122 // Keep track of logged errors so we can know that the build failed. | 122 // Keep track of logged errors so we can know that the build failed. |
| 123 onLog.listen((entry) { | 123 onLog.listen((entry) { |
| 124 if (entry.level == LogLevel.ERROR) _numLogErrors++; | 124 if (entry.level == LogLevel.ERROR) { |
| 125 _accumulatedErrors.add( |
| 126 new TransformerException(entry.transform, entry.message)); |
| 127 } |
| 125 }); | 128 }); |
| 126 } | 129 } |
| 127 | 130 |
| 128 /// Gets the asset identified by [id]. | 131 /// Gets the asset identified by [id]. |
| 129 /// | 132 /// |
| 130 /// If [id] is for a generated or transformed asset, this will wait until it | 133 /// If [id] is for a generated or transformed asset, this will wait until it |
| 131 /// has been created and return it. This means that the returned asset will | 134 /// has been created and return it. This means that the returned asset will |
| 132 /// always be [AssetState.AVAILABLE]. | 135 /// always be [AssetState.AVAILABLE]. |
| 133 /// | 136 /// |
| 134 /// If the asset cannot be found, returns null. | 137 /// If the asset cannot be found, returns null. |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 /// to discard it. | 257 /// to discard it. |
| 255 Future _waitForProcess() { | 258 Future _waitForProcess() { |
| 256 if (_processDone != null) return _processDone; | 259 if (_processDone != null) return _processDone; |
| 257 | 260 |
| 258 _accumulatedErrors = new Queue(); | 261 _accumulatedErrors = new Queue(); |
| 259 _numLogErrors = 0; | 262 _numLogErrors = 0; |
| 260 return _processDone = _process().then((_) { | 263 return _processDone = _process().then((_) { |
| 261 // Report the build completion. | 264 // Report the build completion. |
| 262 // TODO(rnystrom): Put some useful data in here. | 265 // TODO(rnystrom): Put some useful data in here. |
| 263 _resultsController.add( | 266 _resultsController.add( |
| 264 new BuildResult(_accumulatedErrors, _numLogErrors)); | 267 new BuildResult(_accumulatedErrors)); |
| 265 }).catchError((error) { | 268 }).catchError((error) { |
| 266 // If we get here, it's an unexpected error. Runtime errors like missing | 269 // If we get here, it's an unexpected error. Runtime errors like missing |
| 267 // assets should be handled earlier. Errors from transformers or other | 270 // assets should be handled earlier. Errors from transformers or other |
| 268 // external code that barback calls into should be caught at that API | 271 // external code that barback calls into should be caught at that API |
| 269 // boundary. | 272 // boundary. |
| 270 // | 273 // |
| 271 // On the off chance we get here, pipe the error to the results stream | 274 // On the off chance we get here, pipe the error to the results stream |
| 272 // as an error. That will let applications handle it without it appearing | 275 // as an error. That will let applications handle it without it appearing |
| 273 // in the same path as "normal" errors that get reported. | 276 // in the same path as "normal" errors that get reported. |
| 274 _resultsController.addError(error); | 277 _resultsController.addError(error); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 298 | 301 |
| 299 // Otherwise, everything is done. | 302 // Otherwise, everything is done. |
| 300 return; | 303 return; |
| 301 } | 304 } |
| 302 | 305 |
| 303 // Process that phase and then loop onto the next. | 306 // Process that phase and then loop onto the next. |
| 304 return future.then((_) => _process()); | 307 return future.then((_) => _process()); |
| 305 }); | 308 }); |
| 306 } | 309 } |
| 307 } | 310 } |
| OLD | NEW |