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

Unified Diff: pkg/barback/lib/src/phase_input.dart

Issue 260833006: Remove PhaseInput and add TransformerSorter to barback. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rename "sorter" to "classifier". Created 6 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: pkg/barback/lib/src/phase_input.dart
diff --git a/pkg/barback/lib/src/phase_input.dart b/pkg/barback/lib/src/phase_input.dart
deleted file mode 100644
index bd47f1a863b756cce2d0d24b6f0451f89429018a..0000000000000000000000000000000000000000
--- a/pkg/barback/lib/src/phase_input.dart
+++ /dev/null
@@ -1,112 +0,0 @@
-// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-library barback.phase_input;
-
-import 'dart:async';
-
-import 'asset_forwarder.dart';
-import 'asset_node.dart';
-import 'log.dart';
-import 'node_status.dart';
-import 'node_streams.dart';
-import 'phase.dart';
-import 'transform_node.dart';
-import 'transformer.dart';
-
-/// A class for watching a single [AssetNode] and running any transforms that
-/// take that node as a primary input.
-class PhaseInput {
- /// The phase for which this is an input.
- final Phase _phase;
-
- /// A string describing the location of [this] in the transformer graph.
- final String _location;
-
- /// The transforms currently applicable to [input].
- ///
- /// These are the transforms that have been "wired up": they represent a
- /// repeatable transformation of a single concrete set of inputs. "dart2js" is
- /// a transformer. "dart2js on web/main.dart" is a transform.
- final _transforms = new Set<TransformNode>();
-
- /// A forwarder for the input [AssetNode] for this phase.
- ///
- /// This is used to mark the node as removed should the input ever be removed.
- final AssetForwarder _inputForwarder;
-
- /// The asset node for this input.
- AssetNode get input => _inputForwarder.node;
-
- /// The subscription to [input]'s [AssetNode.onStateChange] stream.
- StreamSubscription _inputSubscription;
-
- /// The streams exposed by this input.
- final _streams = new NodeStreams();
- Stream get onStatusChange => _streams.onStatusChange;
- Stream<AssetNode> get onAsset => _streams.onAsset;
- Stream<LogEntry> get onLog => _streams.onLog;
-
- /// How far along [this] is in processing its assets.
- NodeStatus get status {
- var status = input.state.isDirty && !input.isLazy ?
- NodeStatus.MATERIALIZING : NodeStatus.IDLE;
- return status.dirtier(NodeStatus.dirtiest(
- _transforms.map((transform) => transform.status)));
- }
-
- PhaseInput(this._phase, AssetNode input, this._location)
- : _inputForwarder = new AssetForwarder(input) {
- _inputSubscription = input.onStateChange.listen((state) {
- if (state.isRemoved) {
- remove();
- } else {
- _streams.changeStatus(status);
- }
- });
- }
-
- /// Removes this input.
- ///
- /// This marks all outputs of the input as removed.
- void remove() {
- _streams.close();
- _inputSubscription.cancel();
- _inputForwarder.close();
- }
-
- /// Set this input's transformers to [transformers].
- void updateTransformers(Iterable<Transformer> newTransformersIterable) {
- var newTransformers = newTransformersIterable.toSet();
- for (var transform in _transforms.toList()) {
- if (newTransformers.remove(transform.transformer)) continue;
- transform.remove();
- }
-
- // The remaining [newTransformers] are those for which there are no
- // transforms in [_transforms].
- for (var transformer in newTransformers) {
- var transform = new TransformNode(
- _phase, transformer, input, _location);
- _transforms.add(transform);
-
- transform.onStatusChange.listen(
- (_) => _streams.changeStatus(status),
- onDone: () => _transforms.remove(transform));
-
- _streams.onAssetPool.add(transform.onAsset);
- _streams.onLogPool.add(transform.onLog);
- }
- }
-
- /// Force all [LazyTransformer]s' transforms in this input to begin producing
- /// concrete assets.
- void forceAllTransforms() {
- for (var transform in _transforms) {
- transform.force();
- }
- }
-
- String toString() => "phase input in $_location for $input";
-}

Powered by Google App Engine
This is Rietveld 408576698