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

Side by Side Diff: pkg/barback/lib/src/transform_node.dart

Issue 19402003: Rename several classes in barback. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes. Created 7 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « pkg/barback/lib/src/phase.dart ('k') | pkg/barback/test/asset_graph/errors_test.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.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_graph.dart';
11 import 'asset_id.dart'; 10 import 'asset_id.dart';
12 import 'asset_node.dart'; 11 import 'asset_node.dart';
13 import 'asset_set.dart'; 12 import 'asset_set.dart';
14 import 'errors.dart'; 13 import 'errors.dart';
15 import 'phase.dart'; 14 import 'phase.dart';
16 import 'transform.dart'; 15 import 'transform.dart';
17 import 'transformer.dart'; 16 import 'transformer.dart';
18 17
19 /// Describes a transform on a set of assets and its relationship to the build 18 /// Describes a transform on a set of assets and its relationship to the build
20 /// dependency graph. 19 /// dependency graph.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 54
56 /// Applies this transform. 55 /// Applies this transform.
57 /// 56 ///
58 /// Returns a [TransformOutputs] describing the resulting outputs compared to 57 /// Returns a [TransformOutputs] describing the resulting outputs compared to
59 /// previous runs. 58 /// previous runs.
60 Future<TransformOutputs> apply() { 59 Future<TransformOutputs> apply() {
61 var newInputs = new Set<AssetNode>(); 60 var newInputs = new Set<AssetNode>();
62 var newOutputs = new AssetSet(); 61 var newOutputs = new AssetSet();
63 var transform = createTransform(this, newInputs, newOutputs); 62 var transform = createTransform(this, newInputs, newOutputs);
64 return _transformer.apply(transform).catchError((error) { 63 return _transformer.apply(transform).catchError((error) {
65 // Catch all transformer errors and pipe them to the results stream. 64 // Catch all transformer errors and pipe them to the results stream. This
66 // This is so a broken transformer doesn't take down the whole graph. 65 // is so a broken transformer doesn't take down the whole graph.
67 phase.graph.reportError(error); 66 phase.cascade.reportError(error);
68 67
69 // Don't allow partial results from a failed transform. 68 // Don't allow partial results from a failed transform.
70 newOutputs.clear(); 69 newOutputs.clear();
71 }).then((_) { 70 }).then((_) {
72 _isDirty = false; 71 _isDirty = false;
73 72
74 // Stop watching any inputs that were removed. 73 // Stop watching any inputs that were removed.
75 for (var oldInput in _inputs) { 74 for (var oldInput in _inputs) {
76 oldInput.consumers.remove(this); 75 oldInput.consumers.remove(this);
77 } 76 }
78 77
79 // Watch any new inputs so this transform will be re-processed when an 78 // Watch any new inputs so this transform will be re-processed when an
80 // input is modified. 79 // input is modified.
81 for (var newInput in newInputs) { 80 for (var newInput in newInputs) {
82 newInput.consumers.add(this); 81 newInput.consumers.add(this);
83 } 82 }
84 83
85 _inputs = newInputs; 84 _inputs = newInputs;
86 85
87 // See which outputs are missing from the last run. 86 // See which outputs are missing from the last run.
88 var outputIds = newOutputs.map((asset) => asset.id).toSet(); 87 var outputIds = newOutputs.map((asset) => asset.id).toSet();
89 var invalidIds = outputIds 88 var invalidIds = outputIds
90 .where((id) => id.package != phase.graph.package).toSet(); 89 .where((id) => id.package != phase.cascade.package).toSet();
91 outputIds.removeAll(invalidIds); 90 outputIds.removeAll(invalidIds);
92 91
93 for (var id in invalidIds) { 92 for (var id in invalidIds) {
94 // TODO(nweiz): report this as a warning rather than a failing error. 93 // TODO(nweiz): report this as a warning rather than a failing error.
95 phase.graph.reportError( 94 phase.cascade.reportError(
96 new InvalidOutputException(phase.graph.package, id)); 95 new InvalidOutputException(phase.cascade.package, id));
97 } 96 }
98 97
99 var removed = _outputs.difference(outputIds); 98 var removed = _outputs.difference(outputIds);
100 _outputs = outputIds; 99 _outputs = outputIds;
101 100
102 return new TransformOutputs(newOutputs, removed); 101 return new TransformOutputs(newOutputs, removed);
103 }); 102 });
104 } 103 }
105 } 104 }
106 105
107 /// The result of running a [Transform], compared to the previous time it was 106 /// The result of running a [Transform], compared to the previous time it was
108 /// applied. 107 /// applied.
109 class TransformOutputs { 108 class TransformOutputs {
110 /// The outputs that are new or were modified since the last run. 109 /// The outputs that are new or were modified since the last run.
111 final AssetSet updated; 110 final AssetSet updated;
112 111
113 /// The outputs that were created by the previous run but were not generated 112 /// The outputs that were created by the previous run but were not generated
114 /// by the most recent run. 113 /// by the most recent run.
115 final Set<AssetId> removed; 114 final Set<AssetId> removed;
116 115
117 TransformOutputs(this.updated, this.removed); 116 TransformOutputs(this.updated, this.removed);
118 } 117 }
OLDNEW
« no previous file with comments | « pkg/barback/lib/src/phase.dart ('k') | pkg/barback/test/asset_graph/errors_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698