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

Side by Side Diff: lib/src/graph/package_graph.dart

Issue 1947773002: Fix all strong-mode warnings. (Closed) Base URL: git@github.com:dart-lang/barback@master
Patch Set: Code review changes Created 4 years, 7 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
« no previous file with comments | « lib/src/graph/group_runner.dart ('k') | lib/src/graph/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.graph.package_graph; 5 library barback.graph.package_graph;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 9
10 import '../asset/asset_id.dart'; 10 import '../asset/asset_id.dart';
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 } 120 }
121 121
122 /// Gets the asset node identified by [id]. 122 /// Gets the asset node identified by [id].
123 /// 123 ///
124 /// If [id] is for a generated or transformed asset, this will wait until it 124 /// If [id] is for a generated or transformed asset, this will wait until it
125 /// has been created and return it. This means that the returned asset will 125 /// has been created and return it. This means that the returned asset will
126 /// always be [AssetState.AVAILABLE]. 126 /// always be [AssetState.AVAILABLE].
127 /// 127 ///
128 /// If the asset cannot be found, returns null. 128 /// If the asset cannot be found, returns null.
129 Future<AssetNode> getAssetNode(AssetId id) { 129 Future<AssetNode> getAssetNode(AssetId id) {
130 return _inErrorZone(() { 130 return _inErrorZone/*<Future<AssetNode>>*/(() {
131 var cascade = _cascades[id.package]; 131 var cascade = _cascades[id.package];
132 if (cascade != null) return cascade.getAssetNode(id); 132 if (cascade != null) return cascade.getAssetNode(id);
133 return new Future.value(null); 133 return new Future.value(null);
134 }); 134 });
135 } 135 }
136 136
137 /// Returns the stream of newly-emitted assets for the given package's 137 /// Returns the stream of newly-emitted assets for the given package's
138 /// cascade. 138 /// cascade.
139 /// 139 ///
140 /// If there's no cascade for [package], returns `null`. 140 /// If there's no cascade for [package], returns `null`.
(...skipping 10 matching lines...) Expand all
151 /// 151 ///
152 /// Any transforms using [LazyTransformer]s will be forced to generate 152 /// Any transforms using [LazyTransformer]s will be forced to generate
153 /// concrete outputs, and those outputs will be returned. 153 /// concrete outputs, and those outputs will be returned.
154 Future<AssetSet> getAllAssets() { 154 Future<AssetSet> getAllAssets() {
155 for (var cascade in _cascades.values) { 155 for (var cascade in _cascades.values) {
156 _inErrorZone(() => cascade.forceAllTransforms()); 156 _inErrorZone(() => cascade.forceAllTransforms());
157 } 157 }
158 158
159 if (_status != NodeStatus.IDLE) { 159 if (_status != NodeStatus.IDLE) {
160 // A build is still ongoing, so wait for it to complete and try again. 160 // A build is still ongoing, so wait for it to complete and try again.
161 return results.first.then((_) => getAllAssets()); 161 return results.first.then/*<Future<AssetSet>>*/((_) => getAllAssets());
162 } 162 }
163 163
164 // If an unexpected error occurred, complete with that. 164 // If an unexpected error occurred, complete with that.
165 if (_lastUnexpectedError != null) { 165 if (_lastUnexpectedError != null) {
166 var error = _lastUnexpectedError; 166 var error = _lastUnexpectedError;
167 _lastUnexpectedError = null; 167 _lastUnexpectedError = null;
168 return new Future.error(error, _lastUnexpectedErrorTrace); 168 return new Future.error(error, _lastUnexpectedErrorTrace);
169 } 169 }
170 170
171 // If the last build completed with an error, complete the future with it. 171 // If the last build completed with an error, complete the future with it.
172 if (!_lastResult.succeeded) { 172 if (!_lastResult.succeeded) {
173 return new Future.error(BarbackException.aggregate(_lastResult.errors)); 173 return new Future.error(BarbackException.aggregate(_lastResult.errors));
174 } 174 }
175 175
176 // Otherwise, return all of the final output assets. 176 // Otherwise, return all of the final output assets.
177 return Future.wait(_cascades.values.map( 177 return Future.wait(_cascades.values.map(
178 (cascade) => cascade.availableOutputs)) 178 (cascade) => cascade.availableOutputs))
179 .then((assetSets) { 179 .then((assetSets) {
180 var assets = unionAll(assetSets.map((assetSet) => assetSet.toSet())); 180 var assets = unionAll(assetSets.map((assetSet) => assetSet.toSet()));
181 return new Future.value(new AssetSet.from(assets)); 181 return new AssetSet.from(assets);
182 }); 182 });
183 } 183 }
184 184
185 /// Adds [sources] to the graph's known set of source assets. 185 /// Adds [sources] to the graph's known set of source assets.
186 /// 186 ///
187 /// Begins applying any transforms that can consume any of the sources. If a 187 /// Begins applying any transforms that can consume any of the sources. If a
188 /// given source is already known, it is considered modified and all 188 /// given source is already known, it is considered modified and all
189 /// transforms that use it will be re-applied. 189 /// transforms that use it will be re-applied.
190 void updateSources(Iterable<AssetId> sources) { 190 void updateSources(Iterable<AssetId> sources) {
191 groupBy(sources, (id) => id.package).forEach((package, ids) { 191 groupBy(sources, (id) => id.package).forEach((package, ids) {
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 }); 267 });
268 } 268 }
269 269
270 /// Run [body] in an error-handling [Zone] and pipe any unexpected errors to 270 /// Run [body] in an error-handling [Zone] and pipe any unexpected errors to
271 /// the error channel of [results]. 271 /// the error channel of [results].
272 /// 272 ///
273 /// [body] can return a value or a [Future] that will be piped to the returned 273 /// [body] can return a value or a [Future] that will be piped to the returned
274 /// [Future]. If it throws a [BarbackException], that exception will be piped 274 /// [Future]. If it throws a [BarbackException], that exception will be piped
275 /// to the returned [Future] as well. Any other exceptions will be piped to 275 /// to the returned [Future] as well. Any other exceptions will be piped to
276 /// [results]. 276 /// [results].
277 Future _inErrorZone(body()) { 277 Future/*<T>*/ _inErrorZone/*<T>*/(/*=T*/ body()) {
278 var completer = new Completer.sync(); 278 var completer = new Completer/*<T>*/.sync();
279 runZoned(() { 279 runZoned(() {
280 syncFuture(body).then(completer.complete).catchError((error, stackTrace) { 280 new Future.sync(body).then(completer.complete)
281 .catchError((error, stackTrace) {
281 if (error is! BarbackException) throw error; 282 if (error is! BarbackException) throw error;
282 completer.completeError(error, stackTrace); 283 completer.completeError(error, stackTrace);
283 }); 284 });
284 }, onError: (error, stackTrace) { 285 }, onError: (error, stackTrace) {
285 _lastUnexpectedError = error; 286 _lastUnexpectedError = error;
286 _lastUnexpectedErrorTrace = stackTrace; 287 _lastUnexpectedErrorTrace = stackTrace;
287 _resultsController.addError(error, stackTrace); 288 _resultsController.addError(error, stackTrace);
288 }); 289 });
289 return completer.future; 290 return completer.future;
290 } 291 }
291 } 292 }
OLDNEW
« no previous file with comments | « lib/src/graph/group_runner.dart ('k') | lib/src/graph/phase.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698