Remove optional new/const (dart-lang/stream_channel#37) - Run `dartfmt --fix`. - Update version to start working towards next breaking change. - Update minimum SDK to 2.0.0 stable.
diff --git a/pkgs/stream_channel/CHANGELOG.md b/pkgs/stream_channel/CHANGELOG.md index ce98fe0..87ba42f 100644 --- a/pkgs/stream_channel/CHANGELOG.md +++ b/pkgs/stream_channel/CHANGELOG.md
@@ -1,3 +1,8 @@ +## 1.6.9 + +* Require `2.0.0` or newer SDK. +* Drop unnecessary `new` and `const`. + ## 1.6.8 * Set max SDK version to `<3.0.0`, and adjust other dependencies.
diff --git a/pkgs/stream_channel/lib/src/close_guarantee_channel.dart b/pkgs/stream_channel/lib/src/close_guarantee_channel.dart index a2c69bc..b8a3f02 100644 --- a/pkgs/stream_channel/lib/src/close_guarantee_channel.dart +++ b/pkgs/stream_channel/lib/src/close_guarantee_channel.dart
@@ -27,8 +27,8 @@ bool _disconnected = false; CloseGuaranteeChannel(Stream<T> innerStream, StreamSink<T> innerSink) { - _sink = new _CloseGuaranteeSink<T>(innerSink, this); - _stream = new _CloseGuaranteeStream<T>(innerStream, this); + _sink = _CloseGuaranteeSink<T>(innerSink, this); + _stream = _CloseGuaranteeStream<T>(innerStream, this); } }
diff --git a/pkgs/stream_channel/lib/src/disconnector.dart b/pkgs/stream_channel/lib/src/disconnector.dart index 37a376c..9d35cfc 100644 --- a/pkgs/stream_channel/lib/src/disconnector.dart +++ b/pkgs/stream_channel/lib/src/disconnector.dart
@@ -38,11 +38,11 @@ _sinks.clear(); return Future.wait(futures, eagerError: true); }); - final _disconnectMemo = new AsyncMemoizer(); + final _disconnectMemo = AsyncMemoizer(); StreamChannel<T> bind(StreamChannel<T> channel) { return channel.changeSink((innerSink) { - var sink = new _DisconnectorSink<T>(innerSink); + var sink = _DisconnectorSink<T>(innerSink); if (isDisconnected) { // Ignore errors here, because otherwise there would be no way for the @@ -84,9 +84,9 @@ _DisconnectorSink(this._inner); void add(T data) { - if (_closed) throw new StateError("Cannot add event after closing."); + if (_closed) throw StateError("Cannot add event after closing."); if (_inAddStream) { - throw new StateError("Cannot add event while adding stream."); + throw StateError("Cannot add event while adding stream."); } if (_isDisconnected) return; @@ -94,9 +94,9 @@ } void addError(error, [StackTrace stackTrace]) { - if (_closed) throw new StateError("Cannot add event after closing."); + if (_closed) throw StateError("Cannot add event after closing."); if (_inAddStream) { - throw new StateError("Cannot add event while adding stream."); + throw StateError("Cannot add event while adding stream."); } if (_isDisconnected) return; @@ -104,13 +104,13 @@ } Future addStream(Stream<T> stream) { - if (_closed) throw new StateError("Cannot add stream after closing."); + if (_closed) throw StateError("Cannot add stream after closing."); if (_inAddStream) { - throw new StateError("Cannot add stream while adding stream."); + throw StateError("Cannot add stream while adding stream."); } - if (_isDisconnected) return new Future.value(); + if (_isDisconnected) return Future.value(); - _addStreamCompleter = new Completer.sync(); + _addStreamCompleter = Completer.sync(); _addStreamSubscription = stream.listen(_inner.add, onError: _inner.addError, onDone: _addStreamCompleter.complete); return _addStreamCompleter.future.then((_) { @@ -121,7 +121,7 @@ Future close() { if (_inAddStream) { - throw new StateError("Cannot close sink while adding stream."); + throw StateError("Cannot close sink while adding stream."); } _closed = true;
diff --git a/pkgs/stream_channel/lib/src/guarantee_channel.dart b/pkgs/stream_channel/lib/src/guarantee_channel.dart index ba79ed9..e96f5c3 100644 --- a/pkgs/stream_channel/lib/src/guarantee_channel.dart +++ b/pkgs/stream_channel/lib/src/guarantee_channel.dart
@@ -31,18 +31,17 @@ bool _disconnected = false; GuaranteeChannel(Stream<T> innerStream, StreamSink<T> innerSink, - {bool allowSinkErrors: true}) { - _sink = - new _GuaranteeSink<T>(innerSink, this, allowErrors: allowSinkErrors); + {bool allowSinkErrors = true}) { + _sink = _GuaranteeSink<T>(innerSink, this, allowErrors: allowSinkErrors); // Enforce the single-subscription guarantee by changing a broadcast stream // to single-subscription. if (innerStream.isBroadcast) { innerStream = - innerStream.transform(new SingleSubscriptionTransformer<T, T>()); + innerStream.transform(SingleSubscriptionTransformer<T, T>()); } - _streamController = new StreamController<T>( + _streamController = StreamController<T>( onListen: () { // If the sink has disconnected, we've already called // [_streamController.close]. @@ -80,7 +79,7 @@ final GuaranteeChannel<T> _channel; Future get done => _doneCompleter.future; - final _doneCompleter = new Completer(); + final _doneCompleter = Completer(); /// Whether connection is disconnected. /// @@ -108,13 +107,13 @@ /// the underlying sink is closed. final bool _allowErrors; - _GuaranteeSink(this._inner, this._channel, {bool allowErrors: true}) + _GuaranteeSink(this._inner, this._channel, {bool allowErrors = true}) : _allowErrors = allowErrors; void add(T data) { - if (_closed) throw new StateError("Cannot add event after closing."); + if (_closed) throw StateError("Cannot add event after closing."); if (_inAddStream) { - throw new StateError("Cannot add event while adding stream."); + throw StateError("Cannot add event while adding stream."); } if (_disconnected) return; @@ -122,9 +121,9 @@ } void addError(error, [StackTrace stackTrace]) { - if (_closed) throw new StateError("Cannot add event after closing."); + if (_closed) throw StateError("Cannot add event after closing."); if (_inAddStream) { - throw new StateError("Cannot add event while adding stream."); + throw StateError("Cannot add event while adding stream."); } if (_disconnected) return; @@ -153,13 +152,13 @@ } Future addStream(Stream<T> stream) { - if (_closed) throw new StateError("Cannot add stream after closing."); + if (_closed) throw StateError("Cannot add stream after closing."); if (_inAddStream) { - throw new StateError("Cannot add stream while adding stream."); + throw StateError("Cannot add stream while adding stream."); } - if (_disconnected) return new Future.value(); + if (_disconnected) return Future.value(); - _addStreamCompleter = new Completer.sync(); + _addStreamCompleter = Completer.sync(); _addStreamSubscription = stream.listen(_inner.add, onError: _addError, onDone: _addStreamCompleter.complete); return _addStreamCompleter.future.then((_) { @@ -170,7 +169,7 @@ Future close() { if (_inAddStream) { - throw new StateError("Cannot close sink while adding stream."); + throw StateError("Cannot close sink while adding stream."); } if (_closed) return done;
diff --git a/pkgs/stream_channel/lib/src/isolate_channel.dart b/pkgs/stream_channel/lib/src/isolate_channel.dart index d785ae1..c7f573f 100644 --- a/pkgs/stream_channel/lib/src/isolate_channel.dart +++ b/pkgs/stream_channel/lib/src/isolate_channel.dart
@@ -41,10 +41,10 @@ factory IsolateChannel.connectReceive(ReceivePort receivePort) { // We can't use a [StreamChannelCompleter] here because we need the return // value to be an [IsolateChannel]. - var streamCompleter = new StreamCompleter<T>(); - var sinkCompleter = new StreamSinkCompleter<T>(); + var streamCompleter = StreamCompleter<T>(); + var sinkCompleter = StreamSinkCompleter<T>(); var channel = - new IsolateChannel<T>._(streamCompleter.stream, sinkCompleter.sink); + IsolateChannel<T>._(streamCompleter.stream, sinkCompleter.sink); // The first message across the ReceivePort should be a SendPort pointing to // the remote end. If it's not, we'll make the stream emit an error @@ -52,11 +52,9 @@ StreamSubscription<dynamic> subscription; subscription = receivePort.listen((message) { if (message is SendPort) { - var controller = new StreamChannelController<T>( - allowForeignErrors: false, sync: true); - new SubscriptionStream(subscription) - .cast<T>() - .pipe(controller.local.sink); + var controller = + StreamChannelController<T>(allowForeignErrors: false, sync: true); + SubscriptionStream(subscription).cast<T>().pipe(controller.local.sink); controller.local.stream .listen((data) => message.send(data), onDone: receivePort.close); @@ -66,9 +64,9 @@ } streamCompleter.setError( - new StateError('Unexpected Isolate response "$message".'), + StateError('Unexpected Isolate response "$message".'), StackTrace.current); - sinkCompleter.setDestinationSink(new NullStreamSink<T>()); + sinkCompleter.setDestinationSink(NullStreamSink<T>()); subscription.cancel(); }); @@ -85,21 +83,20 @@ /// The connection protocol is guaranteed to remain compatible across versions /// at least until the next major version release. factory IsolateChannel.connectSend(SendPort sendPort) { - var receivePort = new ReceivePort(); + var receivePort = ReceivePort(); sendPort.send(receivePort.sendPort); - return new IsolateChannel(receivePort, sendPort); + return IsolateChannel(receivePort, sendPort); } /// Creates a stream channel that receives messages from [receivePort] and /// sends them over [sendPort]. factory IsolateChannel(ReceivePort receivePort, SendPort sendPort) { var controller = - new StreamChannelController<T>(allowForeignErrors: false, sync: true); + StreamChannelController<T>(allowForeignErrors: false, sync: true); receivePort.cast<T>().pipe(controller.local.sink); controller.local.stream .listen((data) => sendPort.send(data), onDone: receivePort.close); - return new IsolateChannel._( - controller.foreign.stream, controller.foreign.sink); + return IsolateChannel._(controller.foreign.stream, controller.foreign.sink); } IsolateChannel._(this.stream, this.sink);
diff --git a/pkgs/stream_channel/lib/src/json_document_transformer.dart b/pkgs/stream_channel/lib/src/json_document_transformer.dart index 6377eed..2a3a86f 100644 --- a/pkgs/stream_channel/lib/src/json_document_transformer.dart +++ b/pkgs/stream_channel/lib/src/json_document_transformer.dart
@@ -10,7 +10,7 @@ import 'stream_channel_transformer.dart'; /// The canonical instance of [JsonDocumentTransformer]. -final jsonDocument = new JsonDocumentTransformer(); +final jsonDocument = JsonDocumentTransformer(); /// A [StreamChannelTransformer] that transforms JSON documents—strings that /// contain individual objects encoded as JSON—into decoded Dart objects. @@ -31,16 +31,16 @@ /// The [reviver] and [toEncodable] arguments work the same way as the /// corresponding arguments to [new JsonCodec]. JsonDocumentTransformer({reviver(key, value), toEncodable(object)}) - : _codec = new JsonCodec(reviver: reviver, toEncodable: toEncodable); + : _codec = JsonCodec(reviver: reviver, toEncodable: toEncodable); JsonDocumentTransformer._(this._codec); StreamChannel<Object> bind(StreamChannel<String> channel) { var stream = channel.stream.map(_codec.decode); - var sink = new StreamSinkTransformer<Object, String>.fromHandlers( + var sink = StreamSinkTransformer<Object, String>.fromHandlers( handleData: (data, sink) { sink.add(_codec.encode(data)); }).bind(channel.sink); - return new StreamChannel.withCloseGuarantee(stream, sink); + return StreamChannel.withCloseGuarantee(stream, sink); } }
diff --git a/pkgs/stream_channel/lib/src/multi_channel.dart b/pkgs/stream_channel/lib/src/multi_channel.dart index a6d684a..139c9ae 100644 --- a/pkgs/stream_channel/lib/src/multi_channel.dart +++ b/pkgs/stream_channel/lib/src/multi_channel.dart
@@ -58,8 +58,7 @@ /// [inner]. /// /// The inner channel must take JSON-like objects. - factory MultiChannel(StreamChannel<dynamic> inner) => - new _MultiChannel<T>(inner); + factory MultiChannel(StreamChannel<dynamic> inner) => _MultiChannel<T>(inner); /// Creates a new virtual channel. /// @@ -93,7 +92,7 @@ StreamSink<T> get sink => _mainController.foreign.sink; /// The controller for this channel. - final _mainController = new StreamChannelController<T>(sync: true); + final _mainController = StreamChannelController<T>(sync: true); /// A map from input IDs to [StreamChannelController]s that should be used to /// communicate over those channels. @@ -101,11 +100,11 @@ /// Input IDs of controllers in [_controllers] that we've received messages /// for but that have not yet had a local [virtualChannel] created. - final _pendingIds = new Set<int>(); + final _pendingIds = Set<int>(); /// Input IDs of virtual channels that used to exist but have since been /// closed. - final _closedIds = new Set<int>(); + final _closedIds = Set<int>(); /// The next id to use for a local virtual channel. /// @@ -149,7 +148,7 @@ // counterpart yet, create a controller for it to buffer incoming // messages for when a local connection is created. _pendingIds.add(id); - return new StreamChannelController(sync: true); + return StreamChannelController(sync: true); }); if (message.length > 1) { @@ -187,8 +186,7 @@ // If the inner channel has already closed, create new virtual channels in a // closed state. if (_inner == null) { - return new VirtualChannel._( - this, inputId, new Stream.empty(), new NullStreamSink()); + return VirtualChannel._(this, inputId, Stream.empty(), NullStreamSink()); } StreamChannelController<T> controller; @@ -198,16 +196,16 @@ controller = _controllers[inputId]; } else if (_controllers.containsKey(inputId) || _closedIds.contains(inputId)) { - throw new ArgumentError("A virtual channel with id $id already exists."); + throw ArgumentError("A virtual channel with id $id already exists."); } else { - controller = new StreamChannelController(sync: true); + controller = StreamChannelController(sync: true); _controllers[inputId] = controller; } controller.local.stream.listen( (message) => _inner.sink.add([outputId, message]), onDone: () => _closeChannel(inputId, outputId)); - return new VirtualChannel._( + return VirtualChannel._( this, outputId, controller.foreign.stream, controller.foreign.sink); } @@ -234,7 +232,7 @@ // Convert this to a list because the close is dispatched synchronously, and // that could conceivably remove a controller from [_controllers]. - for (var controller in new List.from(_controllers.values)) { + for (var controller in List.from(_controllers.values)) { controller.local.sink.close(); } _controllers.clear();
diff --git a/pkgs/stream_channel/lib/src/stream_channel_completer.dart b/pkgs/stream_channel/lib/src/stream_channel_completer.dart index b9881b9..e94eda6 100644 --- a/pkgs/stream_channel/lib/src/stream_channel_completer.dart +++ b/pkgs/stream_channel/lib/src/stream_channel_completer.dart
@@ -15,10 +15,10 @@ /// any events and all events added to it will be buffered. class StreamChannelCompleter<T> { /// The completer for this channel's stream. - final _streamCompleter = new StreamCompleter<T>(); + final _streamCompleter = StreamCompleter<T>(); /// The completer for this channel's sink. - final _sinkCompleter = new StreamSinkCompleter<T>(); + final _sinkCompleter = StreamSinkCompleter<T>(); /// The channel for this completer. StreamChannel<T> get channel => _channel; @@ -36,14 +36,13 @@ /// instead contain just that error. The sink will silently discard all /// events. static StreamChannel fromFuture(Future<StreamChannel> channelFuture) { - var completer = new StreamChannelCompleter(); + var completer = StreamChannelCompleter(); channelFuture.then(completer.setChannel, onError: completer.setError); return completer.channel; } StreamChannelCompleter() { - _channel = - new StreamChannel<T>(_streamCompleter.stream, _sinkCompleter.sink); + _channel = StreamChannel<T>(_streamCompleter.stream, _sinkCompleter.sink); } /// Set a channel as the source and destination for [channel]. @@ -53,7 +52,7 @@ /// Either [setChannel] or [setError] may be called at most once. Trying to /// call either of them again will fail. void setChannel(StreamChannel<T> channel) { - if (_set) throw new StateError("The channel has already been set."); + if (_set) throw StateError("The channel has already been set."); _set = true; _streamCompleter.setSourceStream(channel.stream); @@ -68,10 +67,10 @@ /// Either [setChannel] or [setError] may be called at most once. Trying to /// call either of them again will fail. void setError(error, [StackTrace stackTrace]) { - if (_set) throw new StateError("The channel has already been set."); + if (_set) throw StateError("The channel has already been set."); _set = true; _streamCompleter.setError(error, stackTrace); - _sinkCompleter.setDestinationSink(new NullStreamSink()); + _sinkCompleter.setDestinationSink(NullStreamSink()); } }
diff --git a/pkgs/stream_channel/lib/src/stream_channel_controller.dart b/pkgs/stream_channel/lib/src/stream_channel_controller.dart index 146e996..136886d 100644 --- a/pkgs/stream_channel/lib/src/stream_channel_controller.dart +++ b/pkgs/stream_channel/lib/src/stream_channel_controller.dart
@@ -52,12 +52,12 @@ /// the foreign channel's sink. If any are, the connection will close and the /// error will be forwarded to the foreign channel's [StreamSink.done] future. /// This guarantees that the local stream will never emit errors. - StreamChannelController({bool allowForeignErrors: true, bool sync: false}) { - var localToForeignController = new StreamController<T>(sync: sync); - var foreignToLocalController = new StreamController<T>(sync: sync); - _local = new StreamChannel<T>.withGuarantees( + StreamChannelController({bool allowForeignErrors = true, bool sync = false}) { + var localToForeignController = StreamController<T>(sync: sync); + var foreignToLocalController = StreamController<T>(sync: sync); + _local = StreamChannel<T>.withGuarantees( foreignToLocalController.stream, localToForeignController.sink); - _foreign = new StreamChannel<T>.withGuarantees( + _foreign = StreamChannel<T>.withGuarantees( localToForeignController.stream, foreignToLocalController.sink, allowSinkErrors: allowForeignErrors); }
diff --git a/pkgs/stream_channel/lib/src/stream_channel_transformer.dart b/pkgs/stream_channel/lib/src/stream_channel_transformer.dart index cc9bad8..32d36b6 100644 --- a/pkgs/stream_channel/lib/src/stream_channel_transformer.dart +++ b/pkgs/stream_channel/lib/src/stream_channel_transformer.dart
@@ -45,7 +45,7 @@ StreamChannelTransformer transformer) => transformer is StreamChannelTransformer<S, T> ? transformer - : new TypeSafeStreamChannelTransformer(transformer); + : TypeSafeStreamChannelTransformer(transformer); /// Creates a [StreamChannelTransformer] from existing stream and sink /// transformers. @@ -58,7 +58,7 @@ /// and all output from its stream is decoded using [Codec.decoder]. StreamChannelTransformer.fromCodec(Codec<S, T> codec) : this(codec.decoder, - new StreamSinkTransformer.fromStreamTransformer(codec.encoder)); + StreamSinkTransformer.fromStreamTransformer(codec.encoder)); /// Transforms the events sent to and emitted by [channel]. /// @@ -68,7 +68,7 @@ /// `channel.straem`, the transformer will transform them and pass the /// transformed versions to the returned channel's stream. StreamChannel<S> bind(StreamChannel<T> channel) => - new StreamChannel<S>.withCloseGuarantee( + StreamChannel<S>.withCloseGuarantee( channel.stream.transform(_streamTransformer), _sinkTransformer.bind(channel.sink)); }
diff --git a/pkgs/stream_channel/lib/stream_channel.dart b/pkgs/stream_channel/lib/stream_channel.dart index ce3cf04..b501160 100644 --- a/pkgs/stream_channel/lib/stream_channel.dart +++ b/pkgs/stream_channel/lib/stream_channel.dart
@@ -72,7 +72,7 @@ /// [StreamChannel] documentation. If they don't do so natively, /// [StreamChannel.withGuarantees] should be used instead. factory StreamChannel(Stream<T> stream, StreamSink<T> sink) => - new _StreamChannel<T>(stream, sink); + _StreamChannel<T>(stream, sink); /// Creates a new [StreamChannel] that communicates over [stream] and [sink]. /// @@ -85,8 +85,8 @@ /// [sink]. If any are, the connection will close and the error will be /// forwarded to [sink].done. factory StreamChannel.withGuarantees(Stream<T> stream, StreamSink<T> sink, - {bool allowSinkErrors: true}) => - new GuaranteeChannel(stream, sink, allowSinkErrors: allowSinkErrors); + {bool allowSinkErrors = true}) => + GuaranteeChannel(stream, sink, allowSinkErrors: allowSinkErrors); /// Creates a new [StreamChannel] that communicates over [stream] and [sink]. /// @@ -99,7 +99,7 @@ /// [StreamChannel.withGuarantees]. factory StreamChannel.withCloseGuarantee( Stream<T> stream, StreamSink<T> sink) => - new CloseGuaranteeChannel(stream, sink); + CloseGuaranteeChannel(stream, sink); /// Connects this to [other], so that any values emitted by either are sent /// directly to the other. @@ -162,11 +162,11 @@ changeSink(transformer.bind); StreamChannel<T> changeStream(Stream<T> change(Stream<T> stream)) => - new StreamChannel.withCloseGuarantee(change(stream), sink); + StreamChannel.withCloseGuarantee(change(stream), sink); StreamChannel<T> changeSink(StreamSink<T> change(StreamSink<T> sink)) => - new StreamChannel.withCloseGuarantee(stream, change(sink)); + StreamChannel.withCloseGuarantee(stream, change(sink)); - StreamChannel<S> cast<S>() => new StreamChannel( + StreamChannel<S> cast<S>() => StreamChannel( DelegatingStream.typed(stream), DelegatingStreamSink.typed(sink)); }
diff --git a/pkgs/stream_channel/pubspec.yaml b/pkgs/stream_channel/pubspec.yaml index 6b1ace3..996cd70 100644 --- a/pkgs/stream_channel/pubspec.yaml +++ b/pkgs/stream_channel/pubspec.yaml
@@ -1,12 +1,12 @@ name: stream_channel -version: 1.6.8 +version: 1.6.9 description: An abstraction for two-way communication channels. author: Dart Team <misc@dartlang.org> homepage: https://github.com/dart-lang/stream_channel environment: - sdk: '>=2.0.0-dev.17.0 <3.0.0' + sdk: '>=2.0.0 <3.0.0' dependencies: async: '>=1.11.0 <3.0.0'
diff --git a/pkgs/stream_channel/test/disconnector_test.dart b/pkgs/stream_channel/test/disconnector_test.dart index 62ef78b..7b36c29 100644 --- a/pkgs/stream_channel/test/disconnector_test.dart +++ b/pkgs/stream_channel/test/disconnector_test.dart
@@ -14,10 +14,10 @@ Disconnector disconnector; StreamChannel channel; setUp(() { - streamController = new StreamController(); - sinkController = new StreamController(); - disconnector = new Disconnector(); - channel = new StreamChannel.withGuarantees( + streamController = StreamController(); + sinkController = StreamController(); + disconnector = Disconnector(); + channel = StreamChannel.withGuarantees( streamController.stream, sinkController.sink) .transform(disconnector); }); @@ -47,17 +47,17 @@ expect(channel.sink.close(), completes); expect(() => channel.sink.add(1), throwsStateError); expect(() => channel.sink.addError("oh no"), throwsStateError); - expect(() => channel.sink.addStream(new Stream.fromIterable([])), + expect(() => channel.sink.addStream(Stream.fromIterable([])), throwsStateError); }); test("events can't be added while a stream is being added", () { - var controller = new StreamController(); + var controller = StreamController(); channel.sink.addStream(controller.stream); expect(() => channel.sink.add(1), throwsStateError); expect(() => channel.sink.addError("oh no"), throwsStateError); - expect(() => channel.sink.addStream(new Stream.fromIterable([])), + expect(() => channel.sink.addStream(Stream.fromIterable([])), throwsStateError); expect(() => channel.sink.close(), throwsStateError); @@ -67,7 +67,7 @@ test("cancels addStream when disconnected", () async { var canceled = false; - var controller = new StreamController(onCancel: () { + var controller = StreamController(onCancel: () { canceled = true; }); expect(channel.sink.addStream(controller.stream), completes); @@ -78,11 +78,11 @@ }); test("disconnect() returns the close future from the inner sink", () async { - var streamController = new StreamController(); - var sinkController = new StreamController(); - var disconnector = new Disconnector(); - var sink = new _CloseCompleterSink(sinkController.sink); - new StreamChannel.withGuarantees(streamController.stream, sink) + var streamController = StreamController(); + var sinkController = StreamController(); + var disconnector = Disconnector(); + var sink = _CloseCompleterSink(sinkController.sink); + StreamChannel.withGuarantees(streamController.stream, sink) .transform(disconnector); var disconnectFutureFired = false; @@ -140,7 +140,7 @@ /// returned by [close] using [completer]. class _CloseCompleterSink extends DelegatingStreamSink { /// The completer for the future returned by [close]. - final completer = new Completer(); + final completer = Completer(); _CloseCompleterSink(StreamSink inner) : super(inner);
diff --git a/pkgs/stream_channel/test/isolate_channel_test.dart b/pkgs/stream_channel/test/isolate_channel_test.dart index 4c73ab0..8971972 100644 --- a/pkgs/stream_channel/test/isolate_channel_test.dart +++ b/pkgs/stream_channel/test/isolate_channel_test.dart
@@ -15,10 +15,10 @@ SendPort sendPort; StreamChannel channel; setUp(() { - receivePort = new ReceivePort(); - var receivePortForSend = new ReceivePort(); + receivePort = ReceivePort(); + var receivePortForSend = ReceivePort(); sendPort = receivePortForSend.sendPort; - channel = new IsolateChannel(receivePortForSend, receivePort.sendPort); + channel = IsolateChannel(receivePortForSend, receivePort.sendPort); }); tearDown(() { @@ -46,17 +46,17 @@ expect(channel.sink.close(), completes); expect(() => channel.sink.add(1), throwsStateError); expect(() => channel.sink.addError("oh no"), throwsStateError); - expect(() => channel.sink.addStream(new Stream.fromIterable([])), + expect(() => channel.sink.addStream(Stream.fromIterable([])), throwsStateError); }); test("events can't be added while a stream is being added", () { - var controller = new StreamController(); + var controller = StreamController(); channel.sink.addStream(controller.stream); expect(() => channel.sink.add(1), throwsStateError); expect(() => channel.sink.addError("oh no"), throwsStateError); - expect(() => channel.sink.addStream(new Stream.fromIterable([])), + expect(() => channel.sink.addStream(Stream.fromIterable([])), throwsStateError); expect(() => channel.sink.close(), throwsStateError); @@ -107,7 +107,7 @@ test("the sink closes as soon as an error is added via addStream", () async { var canceled = false; - var controller = new StreamController(onCancel: () { + var controller = StreamController(onCancel: () { canceled = true; }); @@ -128,7 +128,7 @@ group("connect constructors", () { ReceivePort connectPort; setUp(() { - connectPort = new ReceivePort(); + connectPort = ReceivePort(); }); tearDown(() { @@ -136,8 +136,8 @@ }); test("create a connected pair of channels", () { - var channel1 = new IsolateChannel<int>.connectReceive(connectPort); - var channel2 = new IsolateChannel<int>.connectSend(connectPort.sendPort); + var channel1 = IsolateChannel<int>.connectReceive(connectPort); + var channel2 = IsolateChannel<int>.connectSend(connectPort.sendPort); channel1.sink.add(1); channel1.sink.add(2); @@ -152,7 +152,7 @@ test("the receiving channel produces an error if it gets the wrong message", () { - var connectedChannel = new IsolateChannel.connectReceive(connectPort); + var connectedChannel = IsolateChannel.connectReceive(connectPort); connectPort.sendPort.send("wrong value"); expect(connectedChannel.stream.toList(), throwsStateError);
diff --git a/pkgs/stream_channel/test/json_document_transformer_test.dart b/pkgs/stream_channel/test/json_document_transformer_test.dart index 6cb97f9..83ee099 100644 --- a/pkgs/stream_channel/test/json_document_transformer_test.dart +++ b/pkgs/stream_channel/test/json_document_transformer_test.dart
@@ -13,10 +13,10 @@ StreamController<String> sinkController; StreamChannel<String> channel; setUp(() { - streamController = new StreamController<String>(); - sinkController = new StreamController<String>(); + streamController = StreamController<String>(); + sinkController = StreamController<String>(); channel = - new StreamChannel<String>(streamController.stream, sinkController.sink); + StreamChannel<String>(streamController.stream, sinkController.sink); }); test("decodes JSON emitted by the channel", () { @@ -33,16 +33,16 @@ }); test("supports the reviver function", () { - var transformed = channel.transform( - new JsonDocumentTransformer(reviver: (key, value) => "decoded")); + var transformed = channel + .transform(JsonDocumentTransformer(reviver: (key, value) => "decoded")); streamController.add('{"foo": "bar"}'); expect(transformed.stream.first, completion(equals("decoded"))); }); test("supports the toEncodable function", () { - var transformed = channel.transform( - new JsonDocumentTransformer(toEncodable: (object) => "encoded")); - transformed.sink.add(new Object()); + var transformed = channel + .transform(JsonDocumentTransformer(toEncodable: (object) => "encoded")); + transformed.sink.add(Object()); expect(sinkController.stream.first, completion(equals('"encoded"'))); }); @@ -54,7 +54,7 @@ test("synchronously throws if an unencodable object is added", () { var transformed = channel.transform(jsonDocument); - expect(() => transformed.sink.add(new Object()), - throwsA(new TypeMatcher<JsonUnsupportedObjectError>())); + expect(() => transformed.sink.add(Object()), + throwsA(TypeMatcher<JsonUnsupportedObjectError>())); }); }
diff --git a/pkgs/stream_channel/test/multi_channel_test.dart b/pkgs/stream_channel/test/multi_channel_test.dart index ddc4150..80c595a 100644 --- a/pkgs/stream_channel/test/multi_channel_test.dart +++ b/pkgs/stream_channel/test/multi_channel_test.dart
@@ -10,9 +10,9 @@ MultiChannel channel1; MultiChannel channel2; setUp(() { - controller = new StreamChannelController(); - channel1 = new MultiChannel<int>(controller.local); - channel2 = new MultiChannel<int>(controller.foreign); + controller = StreamChannelController(); + channel1 = MultiChannel<int>(controller.local); + channel2 = MultiChannel<int>(controller.foreign); }); group("the default virtual channel", () {
diff --git a/pkgs/stream_channel/test/stream_channel_completer_test.dart b/pkgs/stream_channel/test/stream_channel_completer_test.dart index 666efe9..c20f9af 100644 --- a/pkgs/stream_channel/test/stream_channel_completer_test.dart +++ b/pkgs/stream_channel/test/stream_channel_completer_test.dart
@@ -13,11 +13,10 @@ StreamController sinkController; StreamChannel innerChannel; setUp(() { - completer = new StreamChannelCompleter(); - streamController = new StreamController(); - sinkController = new StreamController(); - innerChannel = - new StreamChannel(streamController.stream, sinkController.sink); + completer = StreamChannelCompleter(); + streamController = StreamController(); + sinkController = StreamController(); + innerChannel = StreamChannel(streamController.stream, sinkController.sink); }); group("when a channel is set before accessing", () { @@ -97,7 +96,7 @@ group("forFuture", () { test("forwards a StreamChannel", () { var channel = - StreamChannelCompleter.fromFuture(new Future.value(innerChannel)); + StreamChannelCompleter.fromFuture(Future.value(innerChannel)); channel.sink.add(1); channel.sink.close(); streamController.sink.add(2); @@ -108,8 +107,7 @@ }); test("forwards an error", () { - var channel = - StreamChannelCompleter.fromFuture(new Future.error("oh no")); + var channel = StreamChannelCompleter.fromFuture(Future.error("oh no")); expect(channel.stream.toList(), throwsA("oh no")); }); });
diff --git a/pkgs/stream_channel/test/stream_channel_controller_test.dart b/pkgs/stream_channel/test/stream_channel_controller_test.dart index 483b7f6..62f883f 100644 --- a/pkgs/stream_channel/test/stream_channel_controller_test.dart +++ b/pkgs/stream_channel/test/stream_channel_controller_test.dart
@@ -9,7 +9,7 @@ group("asynchronously", () { StreamChannelController controller; setUp(() { - controller = new StreamChannelController(); + controller = StreamChannelController(); }); test("forwards events from the local sink to the foreign stream", () { @@ -33,7 +33,7 @@ test( "with allowForeignErrors: false, shuts down the connection if an " "error is added to the foreign channel", () { - controller = new StreamChannelController(allowForeignErrors: false); + controller = StreamChannelController(allowForeignErrors: false); controller.foreign.sink.addError("oh no"); expect(controller.foreign.sink.done, throwsA("oh no")); @@ -46,7 +46,7 @@ group("synchronously", () { StreamChannelController controller; setUp(() { - controller = new StreamChannelController(sync: true); + controller = StreamChannelController(sync: true); }); test(
diff --git a/pkgs/stream_channel/test/stream_channel_test.dart b/pkgs/stream_channel/test/stream_channel_test.dart index dbe4211..2f05a9e 100644 --- a/pkgs/stream_channel/test/stream_channel_test.dart +++ b/pkgs/stream_channel/test/stream_channel_test.dart
@@ -14,17 +14,17 @@ StreamController sinkController; StreamChannel channel; setUp(() { - streamController = new StreamController(); - sinkController = new StreamController(); - channel = new StreamChannel(streamController.stream, sinkController.sink); + streamController = StreamController(); + sinkController = StreamController(); + channel = StreamChannel(streamController.stream, sinkController.sink); }); test("pipe() pipes data from each channel's stream into the other's sink", () { - var otherStreamController = new StreamController(); - var otherSinkController = new StreamController(); - var otherChannel = new StreamChannel( - otherStreamController.stream, otherSinkController.sink); + var otherStreamController = StreamController(); + var otherSinkController = StreamController(); + var otherChannel = + StreamChannel(otherStreamController.stream, otherSinkController.sink); channel.pipe(otherChannel); streamController.add(1); @@ -43,7 +43,7 @@ test("transform() transforms the channel", () async { var transformed = channel .cast<List<int>>() - .transform(new StreamChannelTransformer.fromCodec(utf8)); + .transform(StreamChannelTransformer.fromCodec(utf8)); streamController.add([102, 111, 111, 98, 97, 114]); streamController.close(); @@ -76,7 +76,7 @@ test("transformSink() transforms only the sink", () async { var transformed = channel.cast<String>().transformSink( - new StreamSinkTransformer.fromStreamTransformer(const LineSplitter())); + StreamSinkTransformer.fromStreamTransformer(const LineSplitter())); streamController.add("fbl\nthp"); streamController.close(); @@ -91,7 +91,7 @@ }); test("changeStream() changes the stream", () { - var newController = new StreamController(); + var newController = StreamController(); var changed = channel.changeStream((stream) { expect(stream, equals(channel.stream)); return newController.stream; @@ -107,7 +107,7 @@ }); test("changeSink() changes the sink", () { - var newController = new StreamController(); + var newController = StreamController(); var changed = channel.changeSink((sink) { expect(sink, equals(channel.sink)); return newController.sink;
diff --git a/pkgs/stream_channel/test/with_close_guarantee_test.dart b/pkgs/stream_channel/test/with_close_guarantee_test.dart index 8e1b631..1749bac 100644 --- a/pkgs/stream_channel/test/with_close_guarantee_test.dart +++ b/pkgs/stream_channel/test/with_close_guarantee_test.dart
@@ -8,18 +8,18 @@ import 'package:stream_channel/stream_channel.dart'; import 'package:test/test.dart'; -final _delayTransformer = new StreamTransformer.fromHandlers( - handleData: (data, sink) => new Future.microtask(() => sink.add(data)), - handleDone: (sink) => new Future.microtask(() => sink.close())); +final _delayTransformer = StreamTransformer.fromHandlers( + handleData: (data, sink) => Future.microtask(() => sink.add(data)), + handleDone: (sink) => Future.microtask(() => sink.close())); final _delaySinkTransformer = - new StreamSinkTransformer.fromStreamTransformer(_delayTransformer); + StreamSinkTransformer.fromStreamTransformer(_delayTransformer); void main() { StreamChannelController controller; StreamChannel channel; setUp(() { - controller = new StreamChannelController(); + controller = StreamChannelController(); // Add a bunch of layers of asynchronous dispatch between the channel and // the underlying controllers. @@ -30,7 +30,7 @@ sink = _delaySinkTransformer.bind(sink); } - channel = new StreamChannel.withCloseGuarantee(stream, sink); + channel = StreamChannel.withCloseGuarantee(stream, sink); }); test(
diff --git a/pkgs/stream_channel/test/with_guarantees_test.dart b/pkgs/stream_channel/test/with_guarantees_test.dart index dcdffe0..0ea5952 100644 --- a/pkgs/stream_channel/test/with_guarantees_test.dart +++ b/pkgs/stream_channel/test/with_guarantees_test.dart
@@ -12,16 +12,16 @@ StreamController sinkController; StreamChannel channel; setUp(() { - streamController = new StreamController(); - sinkController = new StreamController(); - channel = new StreamChannel.withGuarantees( + streamController = StreamController(); + sinkController = StreamController(); + channel = StreamChannel.withGuarantees( streamController.stream, sinkController.sink); }); group("with a broadcast stream", () { setUp(() { - streamController = new StreamController.broadcast(); - channel = new StreamChannel.withGuarantees( + streamController = StreamController.broadcast(); + channel = StreamChannel.withGuarantees( streamController.stream, sinkController.sink); }); @@ -121,17 +121,17 @@ expect(channel.sink.close(), completes); expect(() => channel.sink.add(1), throwsStateError); expect(() => channel.sink.addError("oh no"), throwsStateError); - expect(() => channel.sink.addStream(new Stream.fromIterable([])), + expect(() => channel.sink.addStream(Stream.fromIterable([])), throwsStateError); }); test("events can't be added while a stream is being added", () { - var controller = new StreamController(); + var controller = StreamController(); channel.sink.addStream(controller.stream); expect(() => channel.sink.add(1), throwsStateError); expect(() => channel.sink.addError("oh no"), throwsStateError); - expect(() => channel.sink.addStream(new Stream.fromIterable([])), + expect(() => channel.sink.addStream(Stream.fromIterable([])), throwsStateError); expect(() => channel.sink.close(), throwsStateError); @@ -140,9 +140,9 @@ group("with allowSinkErrors: false", () { setUp(() { - streamController = new StreamController(); - sinkController = new StreamController(); - channel = new StreamChannel.withGuarantees( + streamController = StreamController(); + sinkController = StreamController(); + channel = StreamChannel.withGuarantees( streamController.stream, sinkController.sink, allowSinkErrors: false); }); @@ -180,7 +180,7 @@ "adding an error via via addStream causes the stream to emit a done " "event", () async { var canceled = false; - var controller = new StreamController(onCancel: () { + var controller = StreamController(onCancel: () { canceled = true; });