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

Side by Side Diff: lib/src/graph/asset_cascade.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/errors.dart ('k') | lib/src/graph/group_runner.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.asset_cascade; 5 library barback.graph.asset_cascade;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:async/async.dart';
10
9 import '../asset/asset.dart'; 11 import '../asset/asset.dart';
10 import '../asset/asset_id.dart'; 12 import '../asset/asset_id.dart';
11 import '../asset/asset_node.dart'; 13 import '../asset/asset_node.dart';
12 import '../asset/asset_set.dart'; 14 import '../asset/asset_set.dart';
13 import '../errors.dart'; 15 import '../errors.dart';
14 import '../log.dart'; 16 import '../log.dart';
15 import '../transformer/transformer.dart'; 17 import '../transformer/transformer.dart';
16 import '../utils.dart';
17 import '../utils/cancelable_future.dart'; 18 import '../utils/cancelable_future.dart';
18 import 'node_status.dart'; 19 import 'node_status.dart';
19 import 'node_streams.dart'; 20 import 'node_streams.dart';
20 import 'package_graph.dart'; 21 import 'package_graph.dart';
21 import 'phase.dart'; 22 import 'phase.dart';
22 23
23 /// The asset cascade for an individual package. 24 /// The asset cascade for an individual package.
24 /// 25 ///
25 /// This keeps track of which [Transformer]s are applied to which assets, and 26 /// This keeps track of which [Transformer]s are applied to which assets, and
26 /// re-runs those transformers when their dependencies change. The transformed 27 /// re-runs those transformers when their dependencies change. The transformed
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 107
107 var oldLastPhase = _phases.last; 108 var oldLastPhase = _phases.last;
108 // TODO(rnystrom): Waiting for the entire build to complete is unnecessary 109 // TODO(rnystrom): Waiting for the entire build to complete is unnecessary
109 // in some cases. Should optimize: 110 // in some cases. Should optimize:
110 // * [id] may be generated before the compilation is finished. We should 111 // * [id] may be generated before the compilation is finished. We should
111 // be able to quickly check whether there are any more in-place 112 // be able to quickly check whether there are any more in-place
112 // transformations that can be run on it. If not, we can return it early. 113 // transformations that can be run on it. If not, we can return it early.
113 // * If [id] has never been generated and all active transformers provide 114 // * If [id] has never been generated and all active transformers provide
114 // metadata about the file names of assets it can emit, we can prove that 115 // metadata about the file names of assets it can emit, we can prove that
115 // none of them can emit [id] and fail early. 116 // none of them can emit [id] and fail early.
116 return oldLastPhase.getOutput(id).then((node) { 117 return DelegatingFuture.typed(oldLastPhase.getOutput(id).then((node) {
117 // The last phase may have changed if [updateSources] was called after 118 // The last phase may have changed if [updateSources] was called after
118 // requesting the output. In that case, we want the output from the new 119 // requesting the output. In that case, we want the output from the new
119 // last phase. 120 // last phase.
120 if (_phases.last == oldLastPhase) return node; 121 if (_phases.last == oldLastPhase) return node;
121 return getAssetNode(id); 122 return getAssetNode(id);
122 }); 123 }));
123 } 124 }
124 125
125 /// Adds [sources] to the graph's known set of source assets. 126 /// Adds [sources] to the graph's known set of source assets.
126 /// 127 ///
127 /// Begins applying any transforms that can consume any of the sources. If a 128 /// Begins applying any transforms that can consume any of the sources. If a
128 /// given source is already known, it is considered modified and all 129 /// given source is already known, it is considered modified and all
129 /// transforms that use it will be re-applied. 130 /// transforms that use it will be re-applied.
130 void updateSources(Iterable<AssetId> sources) { 131 void updateSources(Iterable<AssetId> sources) {
131 for (var id in sources) { 132 for (var id in sources) {
132 var controller = _sourceControllerMap[id]; 133 var controller = _sourceControllerMap[id];
133 if (controller != null) { 134 if (controller != null) {
134 controller.setDirty(); 135 controller.setDirty();
135 } else { 136 } else {
136 _sourceControllerMap[id] = new AssetNodeController(id); 137 _sourceControllerMap[id] = new AssetNodeController(id);
137 _phases.first.addInput(_sourceControllerMap[id].node); 138 _phases.first.addInput(_sourceControllerMap[id].node);
138 } 139 }
139 140
140 // If this source was already loading, cancel the old load, since it may 141 // If this source was already loading, cancel the old load, since it may
141 // return out-of-date contents for the asset. 142 // return out-of-date contents for the asset.
142 if (_loadingSources.containsKey(id)) _loadingSources[id].cancel(); 143 if (_loadingSources.containsKey(id)) _loadingSources[id].cancel();
143 144
144 _loadingSources[id] = new CancelableFuture<Asset>( 145 _loadingSources[id] = new CancelableFuture<Asset>(
145 syncFuture(() => graph.provider.getAsset(id))); 146 new Future.sync(() => graph.provider.getAsset(id)));
146 _loadingSources[id].whenComplete(() { 147 _loadingSources[id].whenComplete(() {
147 _loadingSources.remove(id); 148 _loadingSources.remove(id);
148 }).then((asset) { 149 }).then((asset) {
149 var controller = _sourceControllerMap[id].setAvailable(asset); 150 _sourceControllerMap[id].setAvailable(asset);
150 }).catchError((error, stack) { 151 }).catchError((error, stack) {
151 reportError(new AssetLoadException(id, error, stack)); 152 reportError(new AssetLoadException(id, error, stack));
152 153
153 // TODO(nweiz): propagate error information through asset nodes. 154 // TODO(nweiz): propagate error information through asset nodes.
154 _sourceControllerMap.remove(id).setRemoved(); 155 _sourceControllerMap.remove(id).setRemoved();
155 }); 156 });
156 } 157 }
157 } 158 }
158 159
159 /// Removes [removed] from the graph's known set of source assets. 160 /// Removes [removed] from the graph's known set of source assets.
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 _streams.onLogPool.add(phase.onLog); 220 _streams.onLogPool.add(phase.onLog);
220 if (_phaseStatusSubscription != null) _phaseStatusSubscription.cancel(); 221 if (_phaseStatusSubscription != null) _phaseStatusSubscription.cancel();
221 _phaseStatusSubscription = 222 _phaseStatusSubscription =
222 phase.onStatusChange.listen(_streams.changeStatus); 223 phase.onStatusChange.listen(_streams.changeStatus);
223 224
224 _phases.add(phase); 225 _phases.add(phase);
225 } 226 }
226 227
227 String toString() => "cascade for $package"; 228 String toString() => "cascade for $package";
228 } 229 }
OLDNEW
« no previous file with comments | « lib/src/errors.dart ('k') | lib/src/graph/group_runner.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698