summaryrefslogtreecommitdiff
path: root/lib/dart
diff options
context:
space:
mode:
authoraaronstgeorge-wf <aaron.stgeorge@workiva.com>2020-10-01 17:28:28 +0200
committerJens Geyer <jensg@apache.org>2021-03-01 22:59:33 +0100
commit1ab156ab17b6f3268a1ba57034b4d4dc96f4f306 (patch)
treee524440c44d95f9496d006fdb842a3e098788a02 /lib/dart
parent2e90ef569c1b38f6e0f1279e3f25d2a7f6b5ff99 (diff)
downloadthrift-1ab156ab17b6f3268a1ba57034b4d4dc96f4f306.tar.gz
THRIFT-5285 Update http package + update to dart 2 + stylistic changes
Client: Dart Patch: aaronstgeorge-wf This closes #2251
Diffstat (limited to 'lib/dart')
-rw-r--r--lib/dart/.analysis_options2
-rw-r--r--lib/dart/Makefile.am3
-rw-r--r--lib/dart/analysis_options.yaml20
-rw-r--r--lib/dart/lib/src/browser/t_web_socket.dart30
-rw-r--r--lib/dart/lib/src/console/t_tcp_socket.dart18
-rw-r--r--lib/dart/lib/src/console/t_web_socket.dart22
-rw-r--r--lib/dart/lib/src/protocol/t_binary_protocol.dart106
-rw-r--r--lib/dart/lib/src/protocol/t_compact_protocol.dart111
-rw-r--r--lib/dart/lib/src/protocol/t_json_protocol.dart224
-rw-r--r--lib/dart/lib/src/protocol/t_message.dart1
-rw-r--r--lib/dart/lib/src/protocol/t_multiplexed_protocol.dart5
-rw-r--r--lib/dart/lib/src/protocol/t_protocol_decorator.dart41
-rw-r--r--lib/dart/lib/src/protocol/t_protocol_util.dart4
-rw-r--r--lib/dart/lib/src/serializer/t_deserializer.dart15
-rw-r--r--lib/dart/lib/src/serializer/t_serializer.dart14
-rw-r--r--lib/dart/lib/src/t_application_error.dart13
-rw-r--r--lib/dart/lib/src/t_error.dart1
-rw-r--r--lib/dart/lib/src/transport/t_buffered_transport.dart20
-rw-r--r--lib/dart/lib/src/transport/t_framed_transport.dart30
-rw-r--r--lib/dart/lib/src/transport/t_http_transport.dart14
-rw-r--r--lib/dart/lib/src/transport/t_message_reader.dart24
-rw-r--r--lib/dart/lib/src/transport/t_socket_transport.dart27
-rw-r--r--lib/dart/lib/src/transport/t_transport.dart2
-rw-r--r--lib/dart/lib/src/transport/t_transport_factory.dart2
-rw-r--r--lib/dart/lib/thrift.dart7
-rw-r--r--lib/dart/pubspec.yaml17
-rw-r--r--lib/dart/test/protocol/t_protocol_test.dart62
-rw-r--r--lib/dart/test/serializer/serializer_test.dart52
-rw-r--r--lib/dart/test/serializer/serializer_test_data.dart34
-rw-r--r--lib/dart/test/t_application_error_test.dart5
-rw-r--r--lib/dart/test/transport/t_framed_transport_test.dart60
-rw-r--r--lib/dart/test/transport/t_http_transport_test.dart56
-rw-r--r--lib/dart/test/transport/t_socket_transport_test.dart115
-rw-r--r--lib/dart/test/transport/t_transport_test.dart6
-rw-r--r--lib/dart/tool/dev.dart33
35 files changed, 722 insertions, 474 deletions
diff --git a/lib/dart/.analysis_options b/lib/dart/.analysis_options
deleted file mode 100644
index a10d4c5a0..000000000
--- a/lib/dart/.analysis_options
+++ /dev/null
@@ -1,2 +0,0 @@
-analyzer:
- strong-mode: true
diff --git a/lib/dart/Makefile.am b/lib/dart/Makefile.am
index 373a883d6..bd12a92f0 100644
--- a/lib/dart/Makefile.am
+++ b/lib/dart/Makefile.am
@@ -34,6 +34,3 @@ dist-hook:
find $(distdir) -type f -name ".packages" | xargs $(RM)
find $(distdir) -type d -name "packages" | xargs $(RM) -r
-EXTRA_DIST = \
- .analysis_options
-
diff --git a/lib/dart/analysis_options.yaml b/lib/dart/analysis_options.yaml
new file mode 100644
index 000000000..6a8a33c5c
--- /dev/null
+++ b/lib/dart/analysis_options.yaml
@@ -0,0 +1,20 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+include: package:workiva_analysis_options/v1.yaml
diff --git a/lib/dart/lib/src/browser/t_web_socket.dart b/lib/dart/lib/src/browser/t_web_socket.dart
index dac9ffdde..1d0bfeb44 100644
--- a/lib/dart/lib/src/browser/t_web_socket.dart
+++ b/lib/dart/lib/src/browser/t_web_socket.dart
@@ -18,7 +18,7 @@
library thrift.src.browser;
import 'dart:async';
-import 'package:dart2_constant/convert.dart' show base64;
+import 'dart:convert' show base64;
import 'dart:html' show CloseEvent;
import 'dart:html' show Event;
import 'dart:html' show MessageEvent;
@@ -32,39 +32,45 @@ class TWebSocket implements TSocket {
final Uri url;
final StreamController<TSocketState> _onStateController;
+ @override
Stream<TSocketState> get onState => _onStateController.stream;
final StreamController<Object> _onErrorController;
+ @override
Stream<Object> get onError => _onErrorController.stream;
final StreamController<Uint8List> _onMessageController;
+ @override
Stream<Uint8List> get onMessage => _onMessageController.stream;
final List<Uint8List> _requests = [];
TWebSocket(this.url)
- : _onStateController = new StreamController.broadcast(),
- _onErrorController = new StreamController.broadcast(),
- _onMessageController = new StreamController.broadcast() {
+ : _onStateController = StreamController.broadcast(),
+ _onErrorController = StreamController.broadcast(),
+ _onMessageController = StreamController.broadcast() {
if (url == null || !url.hasAuthority || !url.hasPort) {
- throw new ArgumentError('Invalid url');
+ throw ArgumentError('Invalid url');
}
}
WebSocket _socket;
+ @override
bool get isOpen => _socket != null && _socket.readyState == WebSocket.OPEN;
+ @override
bool get isClosed =>
_socket == null || _socket.readyState == WebSocket.CLOSED;
+ @override
Future open() {
if (!isClosed) {
- throw new TTransportError(
+ throw TTransportError(
TTransportErrorType.ALREADY_OPEN, 'Socket already connected');
}
- _socket = new WebSocket(url.toString());
+ _socket = WebSocket(url.toString());
_socket.onError.listen(_onError);
_socket.onOpen.listen(_onOpen);
_socket.onClose.listen(_onClose);
@@ -73,15 +79,17 @@ class TWebSocket implements TSocket {
return _socket.onOpen.first;
}
+ @override
Future close() {
if (_socket != null) {
_socket.close();
return _socket.onClose.first;
} else {
- return new Future.value();
+ return Future.value();
}
}
+ @override
void send(Uint8List data) {
_requests.add(data);
_sendRequests();
@@ -104,7 +112,7 @@ class TWebSocket implements TSocket {
if (_requests.isNotEmpty) {
_onErrorController
- .add(new StateError('Socket was closed with pending requests'));
+ .add(StateError('Socket was closed with pending requests'));
}
_requests.clear();
@@ -113,10 +121,10 @@ class TWebSocket implements TSocket {
void _onMessage(MessageEvent message) {
try {
- Uint8List data = new Uint8List.fromList(base64.decode(message.data));
+ Uint8List data = Uint8List.fromList(base64.decode(message.data));
_onMessageController.add(data);
} on FormatException catch (_) {
- var error = new TProtocolError(TProtocolErrorType.INVALID_DATA,
+ var error = TProtocolError(TProtocolErrorType.INVALID_DATA,
"Expected a Base 64 encoded string.");
_onErrorController.add(error);
}
diff --git a/lib/dart/lib/src/console/t_tcp_socket.dart b/lib/dart/lib/src/console/t_tcp_socket.dart
index b71480334..610d6333c 100644
--- a/lib/dart/lib/src/console/t_tcp_socket.dart
+++ b/lib/dart/lib/src/console/t_tcp_socket.dart
@@ -26,20 +26,23 @@ import 'package:thrift/thrift.dart';
/// A [TSocket] backed by a [Socket] from dart:io
class TTcpSocket implements TSocket {
final StreamController<TSocketState> _onStateController;
+ @override
Stream<TSocketState> get onState => _onStateController.stream;
final StreamController<Object> _onErrorController;
+ @override
Stream<Object> get onError => _onErrorController.stream;
final StreamController<Uint8List> _onMessageController;
+ @override
Stream<Uint8List> get onMessage => _onMessageController.stream;
TTcpSocket(Socket socket)
- : _onStateController = new StreamController.broadcast(),
- _onErrorController = new StreamController.broadcast(),
- _onMessageController = new StreamController.broadcast() {
+ : _onStateController = StreamController.broadcast(),
+ _onErrorController = StreamController.broadcast(),
+ _onMessageController = StreamController.broadcast() {
if (socket == null) {
- throw new ArgumentError.notNull('socket');
+ throw ArgumentError.notNull('socket');
}
_socket = socket;
@@ -48,14 +51,18 @@ class TTcpSocket implements TSocket {
Socket _socket;
+ @override
bool get isOpen => _socket != null;
+ @override
bool get isClosed => _socket == null;
+ @override
Future open() async {
_onStateController.add(TSocketState.OPEN);
}
+ @override
Future close() async {
if (_socket != null) {
await _socket.close();
@@ -65,12 +72,13 @@ class TTcpSocket implements TSocket {
_onStateController.add(TSocketState.CLOSED);
}
+ @override
void send(Uint8List data) {
_socket.add(data);
}
void _onMessage(List<int> message) {
- Uint8List data = new Uint8List.fromList(message);
+ Uint8List data = Uint8List.fromList(message);
_onMessageController.add(data);
}
diff --git a/lib/dart/lib/src/console/t_web_socket.dart b/lib/dart/lib/src/console/t_web_socket.dart
index c938a966f..d69cafe0b 100644
--- a/lib/dart/lib/src/console/t_web_socket.dart
+++ b/lib/dart/lib/src/console/t_web_socket.dart
@@ -18,7 +18,7 @@
library thrift.src.console.t_web_socket;
import 'dart:async';
-import 'package:dart2_constant/convert.dart' show base64;
+import 'dart:convert' show base64;
import 'dart:io';
import 'dart:typed_data' show Uint8List;
@@ -27,20 +27,23 @@ import 'package:thrift/thrift.dart';
/// A [TSocket] backed by a [WebSocket] from dart:io
class TWebSocket implements TSocket {
final StreamController<TSocketState> _onStateController;
+ @override
Stream<TSocketState> get onState => _onStateController.stream;
final StreamController<Object> _onErrorController;
+ @override
Stream<Object> get onError => _onErrorController.stream;
final StreamController<Uint8List> _onMessageController;
+ @override
Stream<Uint8List> get onMessage => _onMessageController.stream;
TWebSocket(WebSocket socket)
- : _onStateController = new StreamController.broadcast(),
- _onErrorController = new StreamController.broadcast(),
- _onMessageController = new StreamController.broadcast() {
+ : _onStateController = StreamController.broadcast(),
+ _onErrorController = StreamController.broadcast(),
+ _onMessageController = StreamController.broadcast() {
if (socket == null) {
- throw new ArgumentError.notNull('socket');
+ throw ArgumentError.notNull('socket');
}
_socket = socket;
@@ -49,14 +52,18 @@ class TWebSocket implements TSocket {
WebSocket _socket;
+ @override
bool get isOpen => _socket != null;
+ @override
bool get isClosed => _socket == null;
+ @override
Future open() async {
_onStateController.add(TSocketState.OPEN);
}
+ @override
Future close() async {
if (_socket != null) {
await _socket.close();
@@ -66,16 +73,17 @@ class TWebSocket implements TSocket {
_onStateController.add(TSocketState.CLOSED);
}
+ @override
void send(Uint8List data) {
_socket.add(base64.encode(data));
}
void _onMessage(String message) {
try {
- Uint8List data = new Uint8List.fromList(base64.decode(message));
+ Uint8List data = Uint8List.fromList(base64.decode(message));
_onMessageController.add(data);
} on FormatException catch (_) {
- var error = new TProtocolError(TProtocolErrorType.INVALID_DATA,
+ var error = TProtocolError(TProtocolErrorType.INVALID_DATA,
"Expected a Base 64 encoded string.");
_onErrorController.add(error);
}
diff --git a/lib/dart/lib/src/protocol/t_binary_protocol.dart b/lib/dart/lib/src/protocol/t_binary_protocol.dart
index a785d811c..9f8f3bf33 100644
--- a/lib/dart/lib/src/protocol/t_binary_protocol.dart
+++ b/lib/dart/lib/src/protocol/t_binary_protocol.dart
@@ -18,13 +18,14 @@
part of thrift;
class TBinaryProtocolFactory implements TProtocolFactory<TBinaryProtocol> {
- TBinaryProtocolFactory({this.strictRead: false, this.strictWrite: true});
+ TBinaryProtocolFactory({this.strictRead = false, this.strictWrite = true});
final bool strictRead;
final bool strictWrite;
+ @override
TBinaryProtocol getProtocol(TTransport transport) {
- return new TBinaryProtocol(transport,
+ return TBinaryProtocol(transport,
strictRead: strictRead, strictWrite: strictWrite);
}
}
@@ -36,16 +37,17 @@ class TBinaryProtocol extends TProtocol {
static const int VERSION_MASK = 0xffff0000;
static const int VERSION_1 = 0x80010000;
- static const Utf8Codec _utf8Codec = const Utf8Codec();
+ static const Utf8Codec _utf8Codec = Utf8Codec();
final bool strictRead;
final bool strictWrite;
TBinaryProtocol(TTransport transport,
- {this.strictRead: false, this.strictWrite: true})
+ {this.strictRead = false, this.strictWrite = true})
: super(transport);
/// write
+ @override
void writeMessageBegin(TMessage message) {
if (strictWrite) {
int version = VERSION_1 | message.type;
@@ -59,75 +61,96 @@ class TBinaryProtocol extends TProtocol {
}
}
+ @override
void writeMessageEnd() {}
+ @override
void writeStructBegin(TStruct struct) {}
+ @override
void writeStructEnd() {}
+ @override
void writeFieldBegin(TField field) {
writeByte(field.type);
writeI16(field.id);
}
+ @override
void writeFieldEnd() {}
+ @override
void writeFieldStop() {
writeByte(TType.STOP);
}
+ @override
void writeMapBegin(TMap map) {
writeByte(map.keyType);
writeByte(map.valueType);
writeI32(map.length);
}
+ @override
void writeMapEnd() {}
+ @override
void writeListBegin(TList list) {
writeByte(list.elementType);
writeI32(list.length);
}
+ @override
void writeListEnd() {}
+ @override
void writeSetBegin(TSet set) {
writeByte(set.elementType);
writeI32(set.length);
}
+ @override
void writeSetEnd() {}
+ @override
void writeBool(bool b) {
if (b == null) b = false;
writeByte(b ? 1 : 0);
}
- final ByteData _byteOut = new ByteData(1);
+ final ByteData _byteOut = ByteData(1);
+
+ @override
void writeByte(int byte) {
if (byte == null) byte = 0;
_byteOut.setUint8(0, byte);
transport.write(_byteOut.buffer.asUint8List(), 0, 1);
}
- final ByteData _i16Out = new ByteData(2);
+ final ByteData _i16Out = ByteData(2);
+
+ @override
void writeI16(int i16) {
if (i16 == null) i16 = 0;
_i16Out.setInt16(0, i16);
transport.write(_i16Out.buffer.asUint8List(), 0, 2);
}
- final ByteData _i32Out = new ByteData(4);
+ final ByteData _i32Out = ByteData(4);
+
+ @override
void writeI32(int i32) {
if (i32 == null) i32 = 0;
_i32Out.setInt32(0, i32);
transport.write(_i32Out.buffer.asUint8List(), 0, 4);
}
- final Uint8List _i64Out = new Uint8List(8);
+ final Uint8List _i64Out = Uint8List(8);
+
+ @override
void writeI64(int i64) {
if (i64 == null) i64 = 0;
- var i = new Int64(i64);
+ var i = Int64(i64);
var bts = i.toBytes();
for (var j = 0; j < 8; j++) {
_i64Out[j] = bts[8 - j - 1];
@@ -135,19 +158,23 @@ class TBinaryProtocol extends TProtocol {
transport.write(_i64Out, 0, 8);
}
+ @override
void writeString(String s) {
- var bytes = s != null ? _utf8Codec.encode(s) : new Uint8List.fromList([]);
+ var bytes = s != null ? _utf8Codec.encode(s) : Uint8List.fromList([]);
writeI32(bytes.length);
transport.write(bytes, 0, bytes.length);
}
- final ByteData _doubleOut = new ByteData(8);
+ final ByteData _doubleOut = ByteData(8);
+
+ @override
void writeDouble(double d) {
if (d == null) d = 0.0;
_doubleOut.setFloat64(0, d);
transport.write(_doubleOut.buffer.asUint8List(), 0, 8);
}
+ @override
void writeBinary(Uint8List bytes) {
var length = bytes.length;
writeI32(length);
@@ -155,6 +182,7 @@ class TBinaryProtocol extends TProtocol {
}
/// read
+ @override
TMessage readMessageBegin() {
String name;
int type;
@@ -164,7 +192,7 @@ class TBinaryProtocol extends TProtocol {
if (size < 0) {
int version = size & VERSION_MASK;
if (version != VERSION_1) {
- throw new TProtocolError(TProtocolErrorType.BAD_VERSION,
+ throw TProtocolError(TProtocolErrorType.BAD_VERSION,
"Bad version in readMessageBegin: $version");
}
type = size & 0x000000ff;
@@ -172,109 +200,133 @@ class TBinaryProtocol extends TProtocol {
seqid = readI32();
} else {
if (strictRead) {
- throw new TProtocolError(TProtocolErrorType.BAD_VERSION,
+ throw TProtocolError(TProtocolErrorType.BAD_VERSION,
"Missing version in readMessageBegin");
}
name = _readString(size);
type = readByte();
seqid = readI32();
}
- return new TMessage(name, type, seqid);
+ return TMessage(name, type, seqid);
}
+ @override
void readMessageEnd() {}
+ @override
TStruct readStructBegin() {
- return new TStruct();
+ return TStruct();
}
+ @override
void readStructEnd() {}
+ @override
TField readFieldBegin() {
String name = "";
int type = readByte();
int id = type != TType.STOP ? readI16() : 0;
- return new TField(name, type, id);
+ return TField(name, type, id);
}
+ @override
void readFieldEnd() {}
+ @override
TMap readMapBegin() {
int keyType = readByte();
int valueType = readByte();
int length = readI32();
- return new TMap(keyType, valueType, length);
+ return TMap(keyType, valueType, length);
}
+ @override
void readMapEnd() {}
+ @override
TList readListBegin() {
int elementType = readByte();
int length = readI32();
- return new TList(elementType, length);
+ return TList(elementType, length);
}
+ @override
void readListEnd() {}
+ @override
TSet readSetBegin() {
int elementType = readByte();
int length = readI32();
- return new TSet(elementType, length);
+ return TSet(elementType, length);
}
+ @override
void readSetEnd() {}
+ @override
bool readBool() => readByte() == 1;
- final Uint8List _byteIn = new Uint8List(1);
+ final Uint8List _byteIn = Uint8List(1);
+
+ @override
int readByte() {
transport.readAll(_byteIn, 0, 1);
return _byteIn.buffer.asByteData().getUint8(0);
}
- final Uint8List _i16In = new Uint8List(2);
+ final Uint8List _i16In = Uint8List(2);
+
+ @override
int readI16() {
transport.readAll(_i16In, 0, 2);
return _i16In.buffer.asByteData().getInt16(0);
}
- final Uint8List _i32In = new Uint8List(4);
+ final Uint8List _i32In = Uint8List(4);
+
+ @override
int readI32() {
transport.readAll(_i32In, 0, 4);
return _i32In.buffer.asByteData().getInt32(0);
}
- final Uint8List _i64In = new Uint8List(8);
+ final Uint8List _i64In = Uint8List(8);
+
+ @override
int readI64() {
transport.readAll(_i64In, 0, 8);
- var i = new Int64.fromBytesBigEndian(_i64In);
+ var i = Int64.fromBytesBigEndian(_i64In);
return i.toInt();
}
- final Uint8List _doubleIn = new Uint8List(8);
+ final Uint8List _doubleIn = Uint8List(8);
+
+ @override
double readDouble() {
transport.readAll(_doubleIn, 0, 8);
return _doubleIn.buffer.asByteData().getFloat64(0);
}
+ @override
String readString() {
int size = readI32();
return _readString(size);
}
String _readString(int size) {
- Uint8List stringIn = new Uint8List(size);
+ Uint8List stringIn = Uint8List(size);
transport.readAll(stringIn, 0, size);
return _utf8Codec.decode(stringIn);
}
+ @override
Uint8List readBinary() {
int length = readI32();
- Uint8List binaryIn = new Uint8List(length);
+ Uint8List binaryIn = Uint8List(length);
transport.readAll(binaryIn, 0, length);
return binaryIn;
}
diff --git a/lib/dart/lib/src/protocol/t_compact_protocol.dart b/lib/dart/lib/src/protocol/t_compact_protocol.dart
index ee8094f8e..dc26722d3 100644
--- a/lib/dart/lib/src/protocol/t_compact_protocol.dart
+++ b/lib/dart/lib/src/protocol/t_compact_protocol.dart
@@ -20,8 +20,9 @@ part of thrift;
class TCompactProtocolFactory implements TProtocolFactory<TCompactProtocol> {
TCompactProtocolFactory();
+ @override
TCompactProtocol getProtocol(TTransport transport) {
- return new TCompactProtocol(transport);
+ return TCompactProtocol(transport);
}
}
@@ -38,7 +39,7 @@ class TCompactProtocol extends TProtocol {
static const int TYPE_MASK = 0xE0;
static const int TYPE_BITS = 0x07;
static const int TYPE_SHIFT_AMOUNT = 5;
- static final TField TSTOP = new TField("", TType.STOP, 0);
+ static final TField TSTOP = TField("", TType.STOP, 0);
static const int TYPE_BOOLEAN_TRUE = 0x01;
static const int TYPE_BOOLEAN_FALSE = 0x02;
@@ -53,7 +54,7 @@ class TCompactProtocol extends TProtocol {
static const int TYPE_MAP = 0x0B;
static const int TYPE_STRUCT = 0x0C;
- static final List<int> _typeMap = new List.unmodifiable(new List(16)
+ static final List<int> _typeMap = List.unmodifiable(List(16)
..[TType.STOP] = TType.STOP
..[TType.BOOL] = TYPE_BOOLEAN_TRUE
..[TType.BYTE] = TYPE_BYTE
@@ -67,40 +68,45 @@ class TCompactProtocol extends TProtocol {
..[TType.MAP] = TYPE_MAP
..[TType.STRUCT] = TYPE_STRUCT);
- static const Utf8Codec _utf8Codec = const Utf8Codec();
+ static const Utf8Codec _utf8Codec = Utf8Codec();
// Pretend this is a stack
- DoubleLinkedQueue<int> _lastField = new DoubleLinkedQueue<int>();
+ DoubleLinkedQueue<int> _lastField = DoubleLinkedQueue<int>();
int _lastFieldId = 0;
- TField _booleanField = null;
- bool _boolValue = null;
+ TField _booleanField;
+ bool _boolValue;
- final Uint8List tempList = new Uint8List(10);
- final ByteData tempBD = new ByteData(10);
+ final Uint8List tempList = Uint8List(10);
+ final ByteData tempBD = ByteData(10);
TCompactProtocol(TTransport transport) : super(transport);
/// Write
+ @override
void writeMessageBegin(TMessage message) {
writeByte(PROTOCOL_ID);
writeByte((VERSION & VERSION_MASK) |
((message.type << TYPE_SHIFT_AMOUNT) & TYPE_MASK));
- _writeVarInt32(new Int32(message.seqid));
+ _writeVarInt32(Int32(message.seqid));
writeString(message.name);
}
+ @override
void writeMessageEnd() {}
+ @override
void writeStructBegin(TStruct struct) {
_lastField.addLast(_lastFieldId);
_lastFieldId = 0;
}
+ @override
void writeStructEnd() {
_lastFieldId = _lastField.removeLast();
}
+ @override
void writeFieldBegin(TField field) {
if (field.type == TType.BOOL) {
_booleanField = field;
@@ -123,36 +129,45 @@ class TCompactProtocol extends TProtocol {
_lastFieldId = field.id;
}
+ @override
void writeFieldEnd() {}
+ @override
void writeFieldStop() {
writeByte(TType.STOP);
}
+ @override
void writeMapBegin(TMap map) {
if (map.length == 0) {
writeByte(0);
} else {
- _writeVarInt32(new Int32(map.length));
+ _writeVarInt32(Int32(map.length));
writeByte(
_getCompactType(map.keyType) << 4 | _getCompactType(map.valueType));
}
}
+ @override
void writeMapEnd() {}
+ @override
void writeListBegin(TList list) {
_writeCollectionBegin(list.elementType, list.length);
}
+ @override
void writeListEnd() {}
+ @override
void writeSetBegin(TSet set) {
_writeCollectionBegin(set.elementType, set.length);
}
+ @override
void writeSetEnd() {}
+ @override
void writeBool(bool b) {
if (b == null) b = false;
if (_booleanField != null) {
@@ -164,41 +179,48 @@ class TCompactProtocol extends TProtocol {
}
}
+ @override
void writeByte(int b) {
if (b == null) b = 0;
tempList[0] = b;
transport.write(tempList, 0, 1);
}
+ @override
void writeI16(int i16) {
if (i16 == null) i16 = 0;
- _writeVarInt32(_int32ToZigZag(new Int32(i16)));
+ _writeVarInt32(_int32ToZigZag(Int32(i16)));
}
+ @override
void writeI32(int i32) {
if (i32 == null) i32 = 0;
- _writeVarInt32(_int32ToZigZag(new Int32(i32)));
+ _writeVarInt32(_int32ToZigZag(Int32(i32)));
}
+ @override
void writeI64(int i64) {
if (i64 == null) i64 = 0;
- _writeVarInt64(_int64ToZigZag(new Int64(i64)));
+ _writeVarInt64(_int64ToZigZag(Int64(i64)));
}
+ @override
void writeDouble(double d) {
if (d == null) d = 0.0;
- tempBD.setFloat64(0, d, Endianness.little);
+ tempBD.setFloat64(0, d, Endian.little);
transport.write(tempBD.buffer.asUint8List(), 0, 8);
}
+ @override
void writeString(String str) {
Uint8List bytes =
- str != null ? _utf8Codec.encode(str) : new Uint8List.fromList([]);
+ str != null ? _utf8Codec.encode(str) : Uint8List.fromList([]);
writeBinary(bytes);
}
+ @override
void writeBinary(Uint8List bytes) {
- _writeVarInt32(new Int32(bytes.length));
+ _writeVarInt32(Int32(bytes.length));
transport.write(bytes, 0, bytes.length);
}
@@ -235,7 +257,7 @@ class TCompactProtocol extends TProtocol {
writeByte(length << 4 | _getCompactType(elemType));
} else {
writeByte(0xF0 | _getCompactType(elemType));
- _writeVarInt32(new Int32(length));
+ _writeVarInt32(Int32(length));
}
}
@@ -247,38 +269,44 @@ class TCompactProtocol extends TProtocol {
return (n << 1) ^ (n >> 63);
}
- /// Read
+
+ // Read
+ @override
TMessage readMessageBegin() {
int protocolId = readByte();
if (protocolId != PROTOCOL_ID) {
- throw new TProtocolError(TProtocolErrorType.BAD_VERSION,
+ throw TProtocolError(TProtocolErrorType.BAD_VERSION,
'Expected protocol id $PROTOCOL_ID but got $protocolId');
}
int versionAndType = readByte();
int version = versionAndType & VERSION_MASK;
if (version != VERSION) {
- throw new TProtocolError(TProtocolErrorType.BAD_VERSION,
+ throw TProtocolError(TProtocolErrorType.BAD_VERSION,
'Expected version $VERSION but got $version');
}
int type = (versionAndType >> TYPE_SHIFT_AMOUNT) & TYPE_BITS;
int seqId = _readVarInt32().toInt();
String messageName = readString();
- return new TMessage(messageName, type, seqId);
+ return TMessage(messageName, type, seqId);
}
+ @override
void readMessageEnd() {}
+ @override
TStruct readStructBegin() {
_lastField.addLast(_lastFieldId);
_lastFieldId = 0;
// TODO make this a constant?
- return new TStruct();
+ return TStruct();
}
+ @override
void readStructEnd() {
_lastFieldId = _lastField.removeLast();
}
+ @override
TField readFieldBegin() {
int type = readByte();
if (type == TType.STOP) {
@@ -293,7 +321,7 @@ class TCompactProtocol extends TProtocol {
fieldId = _lastFieldId + modifier;
}
- TField field = new TField('', _getTType(type & 0x0F), fieldId);
+ TField field = TField('', _getTType(type & 0x0F), fieldId);
if (_isBoolType(type)) {
_boolValue = (type & 0x0F) == TYPE_BOOLEAN_TRUE;
}
@@ -302,8 +330,10 @@ class TCompactProtocol extends TProtocol {
return field;
}
+ @override
void readFieldEnd() {}
+ @override
TMap readMapBegin() {
int length = _readVarInt32().toInt();
_checkNegReadLength(length);
@@ -311,11 +341,13 @@ class TCompactProtocol extends TProtocol {
int keyAndValueType = length == 0 ? 0 : readByte();
int keyType = _getTType(keyAndValueType >> 4);
int valueType = _getTType(keyAndValueType & 0x0F);
- return new TMap(keyType, valueType, length);
+ return TMap(keyType, valueType, length);
}
+ @override
void readMapEnd() {}
+ @override
TList readListBegin() {
int lengthAndType = readByte();
int length = (lengthAndType >> 4) & 0x0F;
@@ -324,18 +356,22 @@ class TCompactProtocol extends TProtocol {
}
_checkNegReadLength(length);
int type = _getTType(lengthAndType);
- return new TList(type, length);
+ return TList(type, length);
}
+ @override
void readListEnd() {}
+ @override
TSet readSetBegin() {
TList tlist = readListBegin();
- return new TSet(tlist.elementType, tlist.length);
+ return TSet(tlist.elementType, tlist.length);
}
+ @override
void readSetEnd() {}
+ @override
bool readBool() {
if (_boolValue != null) {
bool result = _boolValue;
@@ -345,43 +381,50 @@ class TCompactProtocol extends TProtocol {
return readByte() == TYPE_BOOLEAN_TRUE;
}
+ @override
int readByte() {
transport.readAll(tempList, 0, 1);
return tempList.buffer.asByteData().getUint8(0);
}
+ @override
int readI16() {
return _zigzagToInt32(_readVarInt32()).toInt();
}
+ @override
int readI32() {
return _zigzagToInt32(_readVarInt32()).toInt();
}
+ @override
int readI64() {
return _zigzagToInt64(_readVarInt64()).toInt();
}
+ @override
double readDouble() {
transport.readAll(tempList, 0, 8);
- return tempList.buffer.asByteData().getFloat64(0, Endianness.little);
+ return tempList.buffer.asByteData().getFloat64(0, Endian.little);
}
+ @override
String readString() {
int length = _readVarInt32().toInt();
_checkNegReadLength(length);
// TODO look at using temp for small strings?
- Uint8List buff = new Uint8List(length);
+ Uint8List buff = Uint8List(length);
transport.readAll(buff, 0, length);
return _utf8Codec.decode(buff);
}
+ @override
Uint8List readBinary() {
int length = _readVarInt32().toInt();
_checkNegReadLength(length);
- Uint8List buff = new Uint8List(length);
+ Uint8List buff = Uint8List(length);
transport.readAll(buff, 0, length);
return buff;
}
@@ -390,7 +433,7 @@ class TCompactProtocol extends TProtocol {
Int32 result = Int32.ZERO;
int shift = 0;
while (true) {
- Int32 b = new Int32(readByte());
+ Int32 b = Int32(readByte());
result |= (b & 0x7f) << shift;
if ((b & 0x80) != 0x80) break;
shift += 7;
@@ -402,7 +445,7 @@ class TCompactProtocol extends TProtocol {
Int64 result = Int64.ZERO;
int shift = 0;
while (true) {
- Int64 b = new Int64(readByte());
+ Int64 b = Int64(readByte());
result |= (b & 0x7f) << shift;
if ((b & 0x80) != 0x80) break;
shift += 7;
@@ -420,7 +463,7 @@ class TCompactProtocol extends TProtocol {
void _checkNegReadLength(int length) {
if (length < 0) {
- throw new TProtocolError(
+ throw TProtocolError(
TProtocolErrorType.NEGATIVE_SIZE, 'Negative length: $length');
}
}
@@ -457,7 +500,7 @@ class TCompactProtocol extends TProtocol {
case TYPE_STRUCT:
return TType.STRUCT;
default:
- throw new TProtocolError(
+ throw TProtocolError(
TProtocolErrorType.INVALID_DATA, "Unknown type: ${type & 0x0F}");
}
}
diff --git a/lib/dart/lib/src/protocol/t_json_protocol.dart b/lib/dart/lib/src/protocol/t_json_protocol.dart
index 180568ddf..4aaf20cd9 100644
--- a/lib/dart/lib/src/protocol/t_json_protocol.dart
+++ b/lib/dart/lib/src/protocol/t_json_protocol.dart
@@ -18,8 +18,9 @@
part of thrift;
class TJsonProtocolFactory implements TProtocolFactory<TJsonProtocol> {
+ @override
TJsonProtocol getProtocol(TTransport transport) {
- return new TJsonProtocol(transport);
+ return TJsonProtocol(transport);
}
}
@@ -29,18 +30,18 @@ class TJsonProtocolFactory implements TProtocolFactory<TJsonProtocol> {
class TJsonProtocol extends TProtocol {
static const int VERSION_1 = 1;
- static const Utf8Codec utf8Codec = const Utf8Codec();
+ static const Utf8Codec utf8Codec = Utf8Codec();
_BaseContext _context;
_BaseContext _rootContext;
_LookaheadReader _reader;
final List<_BaseContext> _contextStack = [];
- final Uint8List _tempBuffer = new Uint8List(4);
+ final Uint8List _tempBuffer = Uint8List(4);
TJsonProtocol(TTransport transport) : super(transport) {
- _rootContext = new _BaseContext(this);
- _reader = new _LookaheadReader(this);
+ _rootContext = _BaseContext(this);
+ _reader = _LookaheadReader(this);
_resetContext();
}
@@ -63,8 +64,8 @@ class TJsonProtocol extends TProtocol {
void _readJsonSyntaxChar(int charByte) {
int byte = _reader.read();
if (byte != charByte) {
- throw new TProtocolError(TProtocolErrorType.INVALID_DATA,
- "Expected character ${new String.fromCharCode(charByte)} but found: ${new String.fromCharCode(byte)}");
+ throw TProtocolError(TProtocolErrorType.INVALID_DATA,
+ "Expected character ${String.fromCharCode(charByte)} but found: ${String.fromCharCode(byte)}");
}
}
@@ -77,7 +78,7 @@ class TJsonProtocol extends TProtocol {
byte += 10;
return byte - _Constants.HEX_A_BYTES[0];
} else {
- throw new TProtocolError(
+ throw TProtocolError(
TProtocolErrorType.INVALID_DATA, "Expected hex character");
}
}
@@ -164,7 +165,7 @@ class TJsonProtocol extends TProtocol {
void _writeJsonObjectStart() {
_context.write();
transport.writeAll(_Constants.LBRACE_BYTES);
- _pushContext(new _PairContext(this));
+ _pushContext(_PairContext(this));
}
void _writeJsonObjectEnd() {
@@ -175,7 +176,7 @@ class TJsonProtocol extends TProtocol {
void _writeJsonArrayStart() {
_context.write();
transport.writeAll(_Constants.LBRACKET_BYTES);
- _pushContext(new _ListContext(this));
+ _pushContext(_ListContext(this));
}
void _writeJsonArrayEnd() {
@@ -183,6 +184,7 @@ class TJsonProtocol extends TProtocol {
transport.writeAll(_Constants.RBRACKET_BYTES);
}
+ @override
void writeMessageBegin(TMessage message) {
_resetContext();
@@ -194,30 +196,37 @@ class TJsonProtocol extends TProtocol {
_writeJsonInteger(message.seqid);
}
+ @override
void writeMessageEnd() {
_writeJsonArrayEnd();
}
+ @override
void writeStructBegin(TStruct struct) {
_writeJsonObjectStart();
}
+ @override
void writeStructEnd() {
_writeJsonObjectEnd();
}
+ @override
void writeFieldBegin(TField field) {
_writeJsonInteger(field.id);
_writeJsonObjectStart();
_writeJsonString(_Constants.getTypeNameBytesForTypeId(field.type));
}
+ @override
void writeFieldEnd() {
_writeJsonObjectEnd();
}
+ @override
void writeFieldStop() {}
+ @override
void writeMapBegin(TMap map) {
_writeJsonArrayStart();
_writeJsonString(_Constants.getTypeNameBytesForTypeId(map.keyType));
@@ -226,61 +235,74 @@ class TJsonProtocol extends TProtocol {
_writeJsonObjectStart();
}
+ @override
void writeMapEnd() {
_writeJsonObjectEnd();
_writeJsonArrayEnd();
}
+ @override
void writeListBegin(TList list) {
_writeJsonArrayStart();
_writeJsonString(_Constants.getTypeNameBytesForTypeId(list.elementType));
_writeJsonInteger(list.length);
}
+ @override
void writeListEnd() {
_writeJsonArrayEnd();
}
+ @override
void writeSetBegin(TSet set) {
_writeJsonArrayStart();
_writeJsonString(_Constants.getTypeNameBytesForTypeId(set.elementType));
_writeJsonInteger(set.length);
}
+ @override
void writeSetEnd() {
_writeJsonArrayEnd();
}
+ @override
void writeBool(bool b) {
if (b == null) b = false;
_writeJsonInteger(b ? 1 : 0);
}
+ @override
void writeByte(int b) {
_writeJsonInteger(b);
}
+ @override
void writeI16(int i16) {
_writeJsonInteger(i16);
}
+ @override
void writeI32(int i32) {
_writeJsonInteger(i32);
}
+ @override
void writeI64(int i64) {
_writeJsonInteger(i64);
}
+ @override
void writeDouble(double d) {
_writeJsonDouble(d);
}
+ @override
void writeString(String s) {
- var bytes = s != null ? utf8Codec.encode(s) : new Uint8List.fromList([]);
+ var bytes = s != null ? utf8Codec.encode(s) : Uint8List.fromList([]);
_writeJsonString(bytes);
}
+ @override
void writeBinary(Uint8List bytes) {
_writeJsonBase64(bytes);
}
@@ -290,8 +312,7 @@ class TJsonProtocol extends TProtocol {
bool _isLowSurrogate(int b) => b >= 0xDC00 && b <= 0xDFFF;
/// read
-
- Uint8List _readJsonString({bool skipContext: false}) {
+ Uint8List _readJsonString({bool skipContext = false}) {
List<int> bytes = [];
List<int> codeunits = [];
@@ -316,10 +337,10 @@ class TJsonProtocol extends TProtocol {
// distinguish between \uXXXX and control chars like \n
if (byte != _Constants.ESCSEQ_BYTES[1]) {
- String char = new String.fromCharCode(byte);
+ String char = String.fromCharCode(byte);
int offset = _Constants.ESCAPE_CHARS.indexOf(char);
if (offset == -1) {
- throw new TProtocolError(
+ throw TProtocolError(
TProtocolErrorType.INVALID_DATA, "Expected control char");
}
byte = _Constants.ESCAPE_CHAR_VALS.codeUnitAt(offset);
@@ -329,46 +350,44 @@ class TJsonProtocol extends TProtocol {
// it's \uXXXX
transport.readAll(_tempBuffer, 0, 4);
- byte = (_hexVal(_tempBuffer[0]) << 12)
- + (_hexVal(_tempBuffer[1]) << 8)
- + (_hexVal(_tempBuffer[2]) << 4)
- + _hexVal(_tempBuffer[3]);
+ byte = (_hexVal(_tempBuffer[0]) << 12) +
+ (_hexVal(_tempBuffer[1]) << 8) +
+ (_hexVal(_tempBuffer[2]) << 4) +
+ _hexVal(_tempBuffer[3]);
if (_isHighSurrogate(byte)) {
if (codeunits.isNotEmpty) {
- throw new TProtocolError(
+ throw TProtocolError(
TProtocolErrorType.INVALID_DATA, "Expected low surrogate");
}
codeunits.add(byte);
- }
- else if (_isLowSurrogate(byte)) {
+ } else if (_isLowSurrogate(byte)) {
if (codeunits.isEmpty) {
- throw new TProtocolError(
+ throw TProtocolError(
TProtocolErrorType.INVALID_DATA, "Expected high surrogate");
}
codeunits.add(byte);
- bytes.addAll(utf8Codec.encode(new String.fromCharCodes(codeunits)));
+ bytes.addAll(utf8Codec.encode(String.fromCharCodes(codeunits)));
codeunits.clear();
- }
- else {
- bytes.addAll(utf8Codec.encode(new String.fromCharCode(byte)));
+ } else {
+ bytes.addAll(utf8Codec.encode(String.fromCharCode(byte)));
}
}
if (codeunits.isNotEmpty) {
- throw new TProtocolError(
+ throw TProtocolError(
TProtocolErrorType.INVALID_DATA, "Expected low surrogate");
}
- return new Uint8List.fromList(bytes);
+ return Uint8List.fromList(bytes);
}
String _readJsonNumericChars() {
- StringBuffer buffer = new StringBuffer();
+ StringBuffer buffer = StringBuffer();
while (true) {
if (!_Constants.isJsonNumeric(_reader.peek())) {
break;
}
- buffer.write(new String.fromCharCode(_reader.read()));
+ buffer.write(String.fromCharCode(_reader.read()));
}
return buffer.toString();
}
@@ -387,7 +406,7 @@ class TJsonProtocol extends TProtocol {
try {
return int.parse(str);
} on FormatException catch (_) {
- throw new TProtocolError(TProtocolErrorType.INVALID_DATA,
+ throw TProtocolError(TProtocolErrorType.INVALID_DATA,
"Bad data encounted in numeric data");
}
}
@@ -397,12 +416,15 @@ class TJsonProtocol extends TProtocol {
if (_reader.peek() == _Constants.QUOTE_BYTES[0]) {
Uint8List bytes = _readJsonString(skipContext: true);
- double d = double.parse(utf8Codec.decode(bytes), (_) {
- throw new TProtocolError(TProtocolErrorType.INVALID_DATA,
+ double d;
+ try {
+ d = double.tryParse(utf8Codec.decode(bytes));
+ } catch (_) {
+ throw TProtocolError(TProtocolErrorType.INVALID_DATA,
"Bad data encounted in numeric data");
- });
+ }
if (!_context.escapeNumbers && !d.isNaN && !d.isInfinite) {
- throw new TProtocolError(TProtocolErrorType.INVALID_DATA,
+ throw TProtocolError(TProtocolErrorType.INVALID_DATA,
"Numeric data unexpectedly quoted");
}
return d;
@@ -411,10 +433,12 @@ class TJsonProtocol extends TProtocol {
// This will throw - we should have had a quote if escapeNumbers == true
_readJsonSyntaxChar(_Constants.QUOTE_BYTES[0]);
}
- return double.parse(_readJsonNumericChars(), (_) {
- throw new TProtocolError(TProtocolErrorType.INVALID_DATA,
+ try {
+ return double.parse(_readJsonNumericChars());
+ } on FormatException catch (_) {
+ throw TProtocolError(TProtocolErrorType.INVALID_DATA,
"Bad data encounted in numeric data");
- });
+ }
}
}
@@ -423,13 +447,13 @@ class TJsonProtocol extends TProtocol {
Uint8List base64Bytes = _readJsonString();
String base64text = utf8Codec.decode(base64Bytes);
- return new Uint8List.fromList(base64.decode(base64text));
+ return Uint8List.fromList(base64.decode(base64text));
}
void _readJsonObjectStart() {
_context.read();
_readJsonSyntaxChar(_Constants.LBRACE_BYTES[0]);
- _pushContext(new _PairContext(this));
+ _pushContext(_PairContext(this));
}
void _readJsonObjectEnd() {
@@ -440,7 +464,7 @@ class TJsonProtocol extends TProtocol {
void _readJsonArrayStart() {
_context.read();
_readJsonSyntaxChar(_Constants.LBRACKET_BYTES[0]);
- _pushContext(new _ListContext(this));
+ _pushContext(_ListContext(this));
}
void _readJsonArrayEnd() {
@@ -448,12 +472,13 @@ class TJsonProtocol extends TProtocol {
_popContext();
}
+ @override
TMessage readMessageBegin() {
_resetContext();
_readJsonArrayStart();
if (_readJsonInteger() != VERSION_1) {
- throw new TProtocolError(
+ throw TProtocolError(
TProtocolErrorType.BAD_VERSION, "Message contained bad version.");
}
@@ -462,22 +487,26 @@ class TJsonProtocol extends TProtocol {
int type = _readJsonInteger();
int seqid = _readJsonInteger();
- return new TMessage(name, type, seqid);
+ return TMessage(name, type, seqid);
}
+ @override
void readMessageEnd() {
_readJsonArrayEnd();
}
+ @override
TStruct readStructBegin() {
_readJsonObjectStart();
- return new TStruct();
+ return TStruct();
}
+ @override
void readStructEnd() {
_readJsonObjectEnd();
}
+ @override
TField readFieldBegin() {
String name = "";
int type = TType.STOP;
@@ -489,13 +518,15 @@ class TJsonProtocol extends TProtocol {
type = _Constants.getTypeIdForTypeName(_readJsonString());
}
- return new TField(name, type, id);
+ return TField(name, type, id);
}
+ @override
void readFieldEnd() {
_readJsonObjectEnd();
}
+ @override
TMap readMapBegin() {
_readJsonArrayStart();
int keyType = _Constants.getTypeIdForTypeName(_readJsonString());
@@ -503,91 +534,103 @@ class TJsonProtocol extends TProtocol {
int length = _readJsonInteger();
_readJsonObjectStart();
- return new TMap(keyType, valueType, length);
+ return TMap(keyType, valueType, length);
}
+ @override
void readMapEnd() {
_readJsonObjectEnd();
_readJsonArrayEnd();
}
+ @override
TList readListBegin() {
_readJsonArrayStart();
int elementType = _Constants.getTypeIdForTypeName(_readJsonString());
int length = _readJsonInteger();
- return new TList(elementType, length);
+ return TList(elementType, length);
}
+ @override
void readListEnd() {
_readJsonArrayEnd();
}
+ @override
TSet readSetBegin() {
_readJsonArrayStart();
int elementType = _Constants.getTypeIdForTypeName(_readJsonString());
int length = _readJsonInteger();
- return new TSet(elementType, length);
+ return TSet(elementType, length);
}
+ @override
void readSetEnd() {
_readJsonArrayEnd();
}
+ @override
bool readBool() {
return _readJsonInteger() == 0 ? false : true;
}
+ @override
int readByte() {
return _readJsonInteger();
}
+ @override
int readI16() {
return _readJsonInteger();
}
+ @override
int readI32() {
return _readJsonInteger();
}
+ @override
int readI64() {
return _readJsonInteger();
}
+ @override
double readDouble() {
return _readJsonDouble();
}
+ @override
String readString() {
return utf8Codec.decode(_readJsonString());
}
+ @override
Uint8List readBinary() {
- return new Uint8List.fromList(_readJsonBase64());
+ return Uint8List.fromList(_readJsonBase64());
}
}
class _Constants {
- static const utf8codec = const Utf8Codec();
-
- static final Uint8List HEX_0_BYTES = new Uint8List.fromList('0'.codeUnits);
- static final Uint8List HEX_9_BYTES = new Uint8List.fromList('9'.codeUnits);
- static final Uint8List HEX_A_BYTES = new Uint8List.fromList('a'.codeUnits);
- static final Uint8List HEX_F_BYTES = new Uint8List.fromList('f'.codeUnits);
- static final Uint8List COMMA_BYTES = new Uint8List.fromList(','.codeUnits);
- static final Uint8List COLON_BYTES = new Uint8List.fromList(':'.codeUnits);
- static final Uint8List LBRACE_BYTES = new Uint8List.fromList('{'.codeUnits);
- static final Uint8List RBRACE_BYTES = new Uint8List.fromList('}'.codeUnits);
- static final Uint8List LBRACKET_BYTES = new Uint8List.fromList('['.codeUnits);
- static final Uint8List RBRACKET_BYTES = new Uint8List.fromList(']'.codeUnits);
- static final Uint8List QUOTE_BYTES = new Uint8List.fromList('"'.codeUnits);
- static final Uint8List BACKSLASH_BYTES =
- new Uint8List.fromList(r'\'.codeUnits);
-
- static final ESCSEQ_BYTES = new Uint8List.fromList(r'\u00'.codeUnits);
-
- static final Uint8List JSON_CHAR_TABLE = new Uint8List.fromList([
+ static const utf8codec = Utf8Codec();
+
+ static final Uint8List HEX_0_BYTES = Uint8List.fromList('0'.codeUnits);
+ static final Uint8List HEX_9_BYTES = Uint8List.fromList('9'.codeUnits);
+ static final Uint8List HEX_A_BYTES = Uint8List.fromList('a'.codeUnits);
+ static final Uint8List HEX_F_BYTES = Uint8List.fromList('f'.codeUnits);
+ static final Uint8List COMMA_BYTES = Uint8List.fromList(','.codeUnits);
+ static final Uint8List COLON_BYTES = Uint8List.fromList(':'.codeUnits);
+ static final Uint8List LBRACE_BYTES = Uint8List.fromList('{'.codeUnits);
+ static final Uint8List RBRACE_BYTES = Uint8List.fromList('}'.codeUnits);
+ static final Uint8List LBRACKET_BYTES = Uint8List.fromList('['.codeUnits);
+ static final Uint8List RBRACKET_BYTES = Uint8List.fromList(']'.codeUnits);
+ static final Uint8List QUOTE_BYTES = Uint8List.fromList('"'.codeUnits);
+ static final Uint8List BACKSLASH_BYTES = Uint8List.fromList(r'\'.codeUnits);
+
+ static final ESCSEQ_BYTES = Uint8List.fromList(r'\u00'.codeUnits);
+
+ static final Uint8List JSON_CHAR_TABLE = Uint8List.fromList([
0, 0, 0, 0, 0, 0, 0, 0, // 8 bytes
'b'.codeUnitAt(0), 't'.codeUnitAt(0), 'n'.codeUnitAt(0), 0, // 4 bytes
'f'.codeUnitAt(0), 'r'.codeUnitAt(0), 0, 0, // 4 bytes
@@ -612,31 +655,30 @@ class _Constants {
static const String NAME_LIST = 'lst';
static const String NAME_SET = 'set';
- static final Map<int, Uint8List> _TYPE_ID_TO_NAME_BYTES =
- new Map.unmodifiable({
- TType.BOOL: new Uint8List.fromList(NAME_BOOL.codeUnits),
- TType.BYTE: new Uint8List.fromList(NAME_BYTE.codeUnits),
- TType.I16: new Uint8List.fromList(NAME_I16.codeUnits),
- TType.I32: new Uint8List.fromList(NAME_I32.codeUnits),
- TType.I64: new Uint8List.fromList(NAME_I64.codeUnits),
- TType.DOUBLE: new Uint8List.fromList(NAME_DOUBLE.codeUnits),
- TType.STRING: new Uint8List.fromList(NAME_STRING.codeUnits),
- TType.STRUCT: new Uint8List.fromList(NAME_STRUCT.codeUnits),
- TType.MAP: new Uint8List.fromList(NAME_MAP.codeUnits),
- TType.SET: new Uint8List.fromList(NAME_SET.codeUnits),
- TType.LIST: new Uint8List.fromList(NAME_LIST.codeUnits)
+ static final Map<int, Uint8List> _TYPE_ID_TO_NAME_BYTES = Map.unmodifiable({
+ TType.BOOL: Uint8List.fromList(NAME_BOOL.codeUnits),
+ TType.BYTE: Uint8List.fromList(NAME_BYTE.codeUnits),
+ TType.I16: Uint8List.fromList(NAME_I16.codeUnits),
+ TType.I32: Uint8List.fromList(NAME_I32.codeUnits),
+ TType.I64: Uint8List.fromList(NAME_I64.codeUnits),
+ TType.DOUBLE: Uint8List.fromList(NAME_DOUBLE.codeUnits),
+ TType.STRING: Uint8List.fromList(NAME_STRING.codeUnits),
+ TType.STRUCT: Uint8List.fromList(NAME_STRUCT.codeUnits),
+ TType.MAP: Uint8List.fromList(NAME_MAP.codeUnits),
+ TType.SET: Uint8List.fromList(NAME_SET.codeUnits),
+ TType.LIST: Uint8List.fromList(NAME_LIST.codeUnits)
});
static Uint8List getTypeNameBytesForTypeId(int typeId) {
if (!_TYPE_ID_TO_NAME_BYTES.containsKey(typeId)) {
- throw new TProtocolError(
+ throw TProtocolError(
TProtocolErrorType.NOT_IMPLEMENTED, "Unrecognized type");
}
return _TYPE_ID_TO_NAME_BYTES[typeId];
}
- static final Map<String, int> _NAME_TO_TYPE_ID = new Map.unmodifiable({
+ static final Map<String, int> _NAME_TO_TYPE_ID = Map.unmodifiable({
NAME_BOOL: TType.BOOL,
NAME_BYTE: TType.BYTE,
NAME_I16: TType.I16,
@@ -653,14 +695,14 @@ class _Constants {
static int getTypeIdForTypeName(Uint8List bytes) {
String name = utf8codec.decode(bytes);
if (!_NAME_TO_TYPE_ID.containsKey(name)) {
- throw new TProtocolError(
+ throw TProtocolError(
TProtocolErrorType.NOT_IMPLEMENTED, "Unrecognized type");
}
return _NAME_TO_TYPE_ID[name];
}
- static final Set<int> _JSON_NUMERICS = new Set.from([
+ static final Set<int> _JSON_NUMERICS = Set.from([
'+'.codeUnitAt(0),
'-'.codeUnitAt(0),
'.'.codeUnitAt(0),
@@ -689,7 +731,7 @@ class _LookaheadReader {
_LookaheadReader(this.protocol);
bool _hasData = false;
- final Uint8List _data = new Uint8List(1);
+ final Uint8List _data = Uint8List(1);
int read() {
if (_hasData) {
@@ -722,6 +764,7 @@ class _BaseContext {
bool get escapeNumbers => false;
+ @override
String toString() => 'BaseContext';
}
@@ -730,6 +773,7 @@ class _ListContext extends _BaseContext {
bool _first = true;
+ @override
void write() {
if (_first) {
_first = false;
@@ -738,6 +782,7 @@ class _ListContext extends _BaseContext {
}
}
+ @override
void read() {
if (_first) {
_first = false;
@@ -746,6 +791,7 @@ class _ListContext extends _BaseContext {
}
}
+ @override
String toString() => 'ListContext';
}
@@ -758,6 +804,7 @@ class _PairContext extends _BaseContext {
Uint8List get symbolBytes =>
_colon ? _Constants.COLON_BYTES : _Constants.COMMA_BYTES;
+ @override
void write() {
if (_first) {
_first = false;
@@ -768,6 +815,7 @@ class _PairContext extends _BaseContext {
}
}
+ @override
void read() {
if (_first) {
_first = false;
@@ -778,7 +826,9 @@ class _PairContext extends _BaseContext {
}
}
+ @override
bool get escapeNumbers => _colon;
+ @override
String toString() => 'PairContext';
}
diff --git a/lib/dart/lib/src/protocol/t_message.dart b/lib/dart/lib/src/protocol/t_message.dart
index cc7b88680..b985debcc 100644
--- a/lib/dart/lib/src/protocol/t_message.dart
+++ b/lib/dart/lib/src/protocol/t_message.dart
@@ -31,5 +31,6 @@ class TMessage {
TMessage(this.name, this.type, this.seqid);
+ @override
String toString() => "<TMessage name: '$name' type: $type seqid: $seqid>";
}
diff --git a/lib/dart/lib/src/protocol/t_multiplexed_protocol.dart b/lib/dart/lib/src/protocol/t_multiplexed_protocol.dart
index 078a6d72e..693e58bbd 100644
--- a/lib/dart/lib/src/protocol/t_multiplexed_protocol.dart
+++ b/lib/dart/lib/src/protocol/t_multiplexed_protocol.dart
@@ -27,15 +27,16 @@ class TMultiplexedProtocol extends TProtocolDecorator {
: _serviceName = serviceName,
super(protocol) {
if (serviceName == null) {
- throw new ArgumentError.notNull("serviceName");
+ throw ArgumentError.notNull("serviceName");
}
}
+ @override
void writeMessageBegin(TMessage message) {
if (message.type == TMessageType.CALL ||
message.type == TMessageType.ONEWAY) {
String name = _serviceName + SEPARATOR + message.name;
- message = new TMessage(name, message.type, message.seqid);
+ message = TMessage(name, message.type, message.seqid);
}
super.writeMessageBegin(message);
diff --git a/lib/dart/lib/src/protocol/t_protocol_decorator.dart b/lib/dart/lib/src/protocol/t_protocol_decorator.dart
index 9cd02f645..9389ec713 100644
--- a/lib/dart/lib/src/protocol/t_protocol_decorator.dart
+++ b/lib/dart/lib/src/protocol/t_protocol_decorator.dart
@@ -29,122 +29,163 @@ class TProtocolDecorator extends TProtocol {
/// Write
+ @override
void writeMessageBegin(TMessage message) {
_protocol.writeMessageBegin(message);
}
+ @override
void writeMessageEnd() {
_protocol.writeMessageEnd();
}
+ @override
void writeStructBegin(TStruct struct) {
_protocol.writeStructBegin(struct);
}
+ @override
void writeStructEnd() {
_protocol.writeStructEnd();
}
+ @override
void writeFieldBegin(TField field) {
_protocol.writeFieldBegin(field);
}
+ @override
void writeFieldEnd() {
_protocol.writeFieldEnd();
}
+ @override
void writeFieldStop() {
_protocol.writeFieldStop();
}
+ @override
void writeMapBegin(TMap map) {
_protocol.writeMapBegin(map);
}
+ @override
void writeMapEnd() {
_protocol.writeMapEnd();
}
+ @override
void writeListBegin(TList list) {
_protocol.writeListBegin(list);
}
+ @override
void writeListEnd() {
_protocol.writeListEnd();
}
+ @override
void writeSetBegin(TSet set) {
_protocol.writeSetBegin(set);
}
+ @override
void writeSetEnd() {
_protocol.writeSetEnd();
}
+ @override
void writeBool(bool b) {
_protocol.writeBool(b);
}
+ @override
void writeByte(int b) {
_protocol.writeByte(b);
}
+ @override
void writeI16(int i16) {
_protocol.writeI16(i16);
}
+ @override
void writeI32(int i32) {
_protocol.writeI32(i32);
}
+ @override
void writeI64(int i64) {
_protocol.writeI64(i64);
}
+ @override
void writeDouble(double d) {
_protocol.writeDouble(d);
}
+ @override
void writeString(String str) {
_protocol.writeString(str);
}
+ @override
void writeBinary(Uint8List bytes) {
_protocol.writeBinary(bytes);
}
/// Read
+ @override
TMessage readMessageBegin() => _protocol.readMessageBegin();
+ @override
void readMessageEnd() => _protocol.readMessageEnd();
+ @override
TStruct readStructBegin() => _protocol.readStructBegin();
+ @override
void readStructEnd() => _protocol.readStructEnd();
+ @override
TField readFieldBegin() => _protocol.readFieldBegin();
+ @override
void readFieldEnd() => _protocol.readFieldEnd();
+ @override
TMap readMapBegin() => _protocol.readMapBegin();
+ @override
void readMapEnd() => _protocol.readMapEnd();
+ @override
TList readListBegin() => _protocol.readListBegin();
+ @override
void readListEnd() => _protocol.readListEnd();
+ @override
TSet readSetBegin() => _protocol.readSetBegin();
+ @override
void readSetEnd() => _protocol.readSetEnd();
+ @override
bool readBool() => _protocol.readBool();
+ @override
int readByte() => _protocol.readByte();
+ @override
int readI16() => _protocol.readI16();
+ @override
int readI32() => _protocol.readI32();
+ @override
int readI64() => _protocol.readI64();
+ @override
double readDouble() => _protocol.readDouble();
+ @override
String readString() => _protocol.readString();
+ @override
Uint8List readBinary() => _protocol.readBinary();
}
diff --git a/lib/dart/lib/src/protocol/t_protocol_util.dart b/lib/dart/lib/src/protocol/t_protocol_util.dart
index 841ea8217..b57b2c67c 100644
--- a/lib/dart/lib/src/protocol/t_protocol_util.dart
+++ b/lib/dart/lib/src/protocol/t_protocol_util.dart
@@ -29,7 +29,7 @@ class TProtocolUtil {
static _skip(TProtocol prot, int type, int recursionLimit) {
if (recursionLimit <= 0) {
- throw new TProtocolError(
+ throw TProtocolError(
TProtocolErrorType.DEPTH_LIMIT, "Depth limit exceeded");
}
@@ -101,7 +101,7 @@ class TProtocolUtil {
break;
default:
- throw new TProtocolError(TProtocolErrorType.INVALID_DATA, "Invalid data");
+ throw TProtocolError(TProtocolErrorType.INVALID_DATA, "Invalid data");
}
}
}
diff --git a/lib/dart/lib/src/serializer/t_deserializer.dart b/lib/dart/lib/src/serializer/t_deserializer.dart
index aefbee25b..c01ab6bdd 100644
--- a/lib/dart/lib/src/serializer/t_deserializer.dart
+++ b/lib/dart/lib/src/serializer/t_deserializer.dart
@@ -18,30 +18,29 @@
part of thrift;
class TDeserializer {
- final message = new TMessage('Deserializer', TMessageType.ONEWAY, 1);
+ final message = TMessage('Deserializer', TMessageType.ONEWAY, 1);
TBufferedTransport transport;
TProtocol protocol;
TDeserializer({TProtocolFactory protocolFactory}) {
- this.transport = new TBufferedTransport();
-
+ this.transport = TBufferedTransport();
+
if (protocolFactory == null) {
- protocolFactory = new TBinaryProtocolFactory();
+ protocolFactory = TBinaryProtocolFactory();
}
-
+
this.protocol = protocolFactory.getProtocol(this.transport);
}
void read(TBase base, Uint8List data) {
transport.writeAll(data);
-
+
transport.flush();
-
+
base.read(protocol);
}
void readString(TBase base, String data) {
-
transport.writeAll(base64.decode(data));
transport.flush();
diff --git a/lib/dart/lib/src/serializer/t_serializer.dart b/lib/dart/lib/src/serializer/t_serializer.dart
index feec8226d..fb897895d 100644
--- a/lib/dart/lib/src/serializer/t_serializer.dart
+++ b/lib/dart/lib/src/serializer/t_serializer.dart
@@ -18,15 +18,15 @@
part of thrift;
class TSerializer {
- final message = new TMessage('Serializer', TMessageType.ONEWAY, 1);
+ final message = TMessage('Serializer', TMessageType.ONEWAY, 1);
TBufferedTransport transport;
TProtocol protocol;
TSerializer({TProtocolFactory protocolFactory}) {
- this.transport = new TBufferedTransport();
-
+ this.transport = TBufferedTransport();
+
if (protocolFactory == null) {
- protocolFactory = new TBinaryProtocolFactory();
+ protocolFactory = TBinaryProtocolFactory();
}
this.protocol = protocolFactory.getProtocol(this.transport);
@@ -34,15 +34,15 @@ class TSerializer {
Uint8List write(TBase base) {
base.write(protocol);
-
+
return transport.consumeWriteBuffer();
}
String writeString(TBase base) {
base.write(protocol);
-
+
Uint8List bytes = transport.consumeWriteBuffer();
-
+
return base64.encode(bytes);
}
}
diff --git a/lib/dart/lib/src/t_application_error.dart b/lib/dart/lib/src/t_application_error.dart
index 6f8abd4bd..38449a9a4 100644
--- a/lib/dart/lib/src/t_application_error.dart
+++ b/lib/dart/lib/src/t_application_error.dart
@@ -32,12 +32,11 @@ class TApplicationErrorType {
}
class TApplicationError extends TError {
- static final TStruct _struct = new TStruct("TApplicationError");
+ static final TStruct _struct = TStruct("TApplicationError");
static const int MESSAGE = 1;
- static final TField _messageField =
- new TField("message", TType.STRING, MESSAGE);
+ static final TField _messageField = TField("message", TType.STRING, MESSAGE);
static const int TYPE = 2;
- static final TField _typeField = new TField("type", TType.I32, TYPE);
+ static final TField _typeField = TField("type", TType.I32, TYPE);
TApplicationError(
[int type = TApplicationErrorType.UNKNOWN, String message = ""])
@@ -46,7 +45,7 @@ class TApplicationError extends TError {
static TApplicationError read(TProtocol iprot) {
TField field;
- String message = null;
+ String message;
int type = TApplicationErrorType.UNKNOWN;
iprot.readStructBegin();
@@ -82,13 +81,13 @@ class TApplicationError extends TError {
}
iprot.readStructEnd();
- return new TApplicationError(type, message);
+ return TApplicationError(type, message);
}
write(TProtocol oprot) {
oprot.writeStructBegin(_struct);
- if (message != null && !message.isEmpty) {
+ if (message != null && message.isNotEmpty) {
oprot.writeFieldBegin(_messageField);
oprot.writeString(message);
oprot.writeFieldEnd();
diff --git a/lib/dart/lib/src/t_error.dart b/lib/dart/lib/src/t_error.dart
index 93ab73239..df157915a 100644
--- a/lib/dart/lib/src/t_error.dart
+++ b/lib/dart/lib/src/t_error.dart
@@ -23,5 +23,6 @@ class TError extends Error {
TError(this.type, this.message);
+ @override
String toString() => "<TError type: $type message: '$message'>";
}
diff --git a/lib/dart/lib/src/transport/t_buffered_transport.dart b/lib/dart/lib/src/transport/t_buffered_transport.dart
index b73a30c0e..f17b2eecf 100644
--- a/lib/dart/lib/src/transport/t_buffered_transport.dart
+++ b/lib/dart/lib/src/transport/t_buffered_transport.dart
@@ -23,7 +23,7 @@ class TBufferedTransport extends TTransport {
Iterator<int> _readIterator;
Uint8List consumeWriteBuffer() {
- Uint8List buffer = new Uint8List.fromList(_writeBuffer);
+ Uint8List buffer = Uint8List.fromList(_writeBuffer);
_writeBuffer.clear();
return buffer;
}
@@ -32,7 +32,7 @@ class TBufferedTransport extends TTransport {
_readIterator = readBuffer != null ? readBuffer.iterator : null;
}
- void _reset({bool isOpen: false}) {
+ void _reset({bool isOpen = false}) {
_isOpen = isOpen;
_writeBuffer.clear();
_readIterator = null;
@@ -41,23 +41,27 @@ class TBufferedTransport extends TTransport {
bool get hasReadData => _readIterator != null;
bool _isOpen;
+ @override
bool get isOpen => _isOpen;
+ @override
Future open() async {
_reset(isOpen: true);
}
+ @override
Future close() async {
_reset(isOpen: false);
}
+ @override
int read(Uint8List buffer, int offset, int length) {
if (buffer == null) {
- throw new ArgumentError.notNull("buffer");
+ throw ArgumentError.notNull("buffer");
}
if (offset + length > buffer.length) {
- throw new ArgumentError("The range exceeds the buffer length");
+ throw ArgumentError("The range exceeds the buffer length");
}
if (_readIterator == null || length <= 0) {
@@ -78,21 +82,23 @@ class TBufferedTransport extends TTransport {
return i;
}
+ @override
void write(Uint8List buffer, int offset, int length) {
if (buffer == null) {
- throw new ArgumentError.notNull("buffer");
+ throw ArgumentError.notNull("buffer");
}
if (offset + length > buffer.length) {
- throw new ArgumentError("The range exceeds the buffer length");
+ throw ArgumentError("The range exceeds the buffer length");
}
_writeBuffer.addAll(buffer.sublist(offset, offset + length));
}
+ @override
Future flush() {
_readIterator = consumeWriteBuffer().iterator;
- return new Future.value();
+ return Future.value();
}
}
diff --git a/lib/dart/lib/src/transport/t_framed_transport.dart b/lib/dart/lib/src/transport/t_framed_transport.dart
index 2ef03f7f8..3fc55fa09 100644
--- a/lib/dart/lib/src/transport/t_framed_transport.dart
+++ b/lib/dart/lib/src/transport/t_framed_transport.dart
@@ -25,33 +25,37 @@ class TFramedTransport extends TBufferedTransport {
final TTransport _transport;
- final Uint8List _headerBytes = new Uint8List(headerByteCount);
+ final Uint8List _headerBytes = Uint8List(headerByteCount);
int _receivedHeaderBytes = 0;
int _bodySize = 0;
- Uint8List _body = null;
+ Uint8List _body;
int _receivedBodyBytes = 0;
- Completer<Uint8List> _frameCompleter = null;
+ Completer<Uint8List> _frameCompleter;
TFramedTransport(TTransport transport) : _transport = transport {
if (transport == null) {
- throw new ArgumentError.notNull("transport");
+ throw ArgumentError.notNull("transport");
}
}
+ @override
bool get isOpen => _transport.isOpen;
+ @override
Future open() {
_reset(isOpen: true);
return _transport.open();
}
+ @override
Future close() {
_reset(isOpen: false);
return _transport.close();
}
+ @override
int read(Uint8List buffer, int offset, int length) {
if (hasReadData) {
int got = super.read(buffer, offset, length);
@@ -78,10 +82,11 @@ class TFramedTransport extends TBufferedTransport {
bool _readFrameHeader() {
var remainingHeaderBytes = headerByteCount - _receivedHeaderBytes;
- int got = _transport.read(_headerBytes, _receivedHeaderBytes, remainingHeaderBytes);
+ int got = _transport.read(
+ _headerBytes, _receivedHeaderBytes, remainingHeaderBytes);
if (got < 0) {
- throw new TTransportError(
- TTransportErrorType.UNKNOWN, "Socket closed during frame header read");
+ throw TTransportError(TTransportErrorType.UNKNOWN,
+ "Socket closed during frame header read");
}
_receivedHeaderBytes += got;
@@ -92,12 +97,12 @@ class TFramedTransport extends TBufferedTransport {
_receivedHeaderBytes = 0;
if (size < 0) {
- throw new TTransportError(
+ throw TTransportError(
TTransportErrorType.UNKNOWN, "Read a negative frame size: $size");
}
_bodySize = size;
- _body = new Uint8List(_bodySize);
+ _body = Uint8List(_bodySize);
_receivedBodyBytes = 0;
return true;
@@ -112,7 +117,7 @@ class TFramedTransport extends TBufferedTransport {
int got = _transport.read(_body, _receivedBodyBytes, remainingBodyBytes);
if (got < 0) {
- throw new TTransportError(
+ throw TTransportError(
TTransportErrorType.UNKNOWN, "Socket closed during frame body read");
}
@@ -129,12 +134,13 @@ class TFramedTransport extends TBufferedTransport {
var completer = _frameCompleter;
_frameCompleter = null;
- completer.complete(new Uint8List(0));
+ completer.complete(Uint8List(0));
} else {
_registerForReadableBytes();
}
}
+ @override
Future flush() {
if (_frameCompleter == null) {
Uint8List buffer = consumeWriteBuffer();
@@ -144,7 +150,7 @@ class TFramedTransport extends TBufferedTransport {
_transport.write(_headerBytes, 0, headerByteCount);
_transport.write(buffer, 0, length);
- _frameCompleter = new Completer<Uint8List>();
+ _frameCompleter = Completer<Uint8List>();
_registerForReadableBytes();
}
diff --git a/lib/dart/lib/src/transport/t_http_transport.dart b/lib/dart/lib/src/transport/t_http_transport.dart
index 630213fbf..71fdb3cd9 100644
--- a/lib/dart/lib/src/transport/t_http_transport.dart
+++ b/lib/dart/lib/src/transport/t_http_transport.dart
@@ -34,31 +34,33 @@ class THttpClientTransport extends TBufferedTransport {
THttpClientTransport(this.httpClient, this.config) {
if (httpClient == null) {
- throw new ArgumentError.notNull("httpClient");
+ throw ArgumentError.notNull("httpClient");
}
}
+ @override
Future close() async {
_reset(isOpen: false);
httpClient.close();
}
+ @override
Future flush() {
var requestBody = base64.encode(consumeWriteBuffer());
// Use a sync completer to ensure that the buffer can be read immediately
// after the read buffer is set, and avoid a race condition where another
// response could overwrite the read buffer.
- var completer = new Completer.sync();
+ var completer = Completer.sync();
httpClient
.post(config.url, headers: config.headers, body: requestBody)
.then((response) {
Uint8List data;
try {
- data = new Uint8List.fromList(base64.decode(response.body));
+ data = Uint8List.fromList(base64.decode(response.body));
} on FormatException catch (_) {
- throw new TProtocolError(TProtocolErrorType.INVALID_DATA,
+ throw TProtocolError(TProtocolErrorType.INVALID_DATA,
"Expected a Base 64 encoded string.");
}
@@ -78,7 +80,7 @@ class THttpConfig {
THttpConfig(this.url, Map<String, String> headers) {
if (url == null || !url.hasAuthority) {
- throw new ArgumentError("Invalid url");
+ throw ArgumentError("Invalid url");
}
_initHeaders(headers);
@@ -94,6 +96,6 @@ class THttpConfig {
h['Content-Type'] = 'application/x-thrift';
h['Accept'] = 'application/x-thrift';
- _headers = new Map.unmodifiable(h);
+ _headers = Map.unmodifiable(h);
}
}
diff --git a/lib/dart/lib/src/transport/t_message_reader.dart b/lib/dart/lib/src/transport/t_message_reader.dart
index 8ca070834..620a27a9f 100644
--- a/lib/dart/lib/src/transport/t_message_reader.dart
+++ b/lib/dart/lib/src/transport/t_message_reader.dart
@@ -27,8 +27,8 @@ class TMessageReader {
/// Construct a [MessageReader]. The optional [byteOffset] specifies the
/// number of bytes to skip before reading the [TMessage].
- TMessageReader(this.protocolFactory, {int byteOffset: 0})
- : _transport = new _TMessageReaderTransport(),
+ TMessageReader(this.protocolFactory, {int byteOffset = 0})
+ : _transport = _TMessageReaderTransport(),
this.byteOffset = byteOffset;
TMessage readMessage(Uint8List bytes) {
@@ -54,7 +54,7 @@ class _TMessageReaderTransport extends TTransport {
}
if (offset > bytes.length) {
- throw new ArgumentError("The offset exceeds the bytes length");
+ throw ArgumentError("The offset exceeds the bytes length");
}
_readIterator = bytes.iterator;
@@ -64,19 +64,23 @@ class _TMessageReaderTransport extends TTransport {
}
}
+ @override
get isOpen => true;
- Future open() => throw new UnsupportedError("Unsupported in MessageReader");
+ @override
+ Future open() => throw UnsupportedError("Unsupported in MessageReader");
- Future close() => throw new UnsupportedError("Unsupported in MessageReader");
+ @override
+ Future close() => throw UnsupportedError("Unsupported in MessageReader");
+ @override
int read(Uint8List buffer, int offset, int length) {
if (buffer == null) {
- throw new ArgumentError.notNull("buffer");
+ throw ArgumentError.notNull("buffer");
}
if (offset + length > buffer.length) {
- throw new ArgumentError("The range exceeds the buffer length");
+ throw ArgumentError("The range exceeds the buffer length");
}
if (_readIterator == null || length <= 0) {
@@ -92,8 +96,10 @@ class _TMessageReaderTransport extends TTransport {
return i;
}
+ @override
void write(Uint8List buffer, int offset, int length) =>
- throw new UnsupportedError("Unsupported in MessageReader");
+ throw UnsupportedError("Unsupported in MessageReader");
- Future flush() => throw new UnsupportedError("Unsupported in MessageReader");
+ @override
+ Future flush() => throw UnsupportedError("Unsupported in MessageReader");
}
diff --git a/lib/dart/lib/src/transport/t_socket_transport.dart b/lib/dart/lib/src/transport/t_socket_transport.dart
index c41374aff..d9929c89b 100644
--- a/lib/dart/lib/src/transport/t_socket_transport.dart
+++ b/lib/dart/lib/src/transport/t_socket_transport.dart
@@ -28,27 +28,30 @@ part of thrift;
///
/// Adapted from the JS WebSocket transport.
abstract class TSocketTransport extends TBufferedTransport {
- final Logger logger = new Logger('thrift.TSocketTransport');
+ final Logger logger = Logger('thrift.TSocketTransport');
final TSocket socket;
/// A transport using the provided [socket].
TSocketTransport(this.socket) {
if (socket == null) {
- throw new ArgumentError.notNull('socket');
+ throw ArgumentError.notNull('socket');
}
socket.onError.listen((e) => logger.warning(e));
socket.onMessage.listen(handleIncomingMessage);
}
+ @override
bool get isOpen => socket.isOpen;
+ @override
Future open() {
_reset(isOpen: true);
return socket.open();
}
+ @override
Future close() {
_reset(isOpen: false);
return socket.close();
@@ -70,13 +73,14 @@ class TClientSocketTransport extends TSocketTransport {
TClientSocketTransport(TSocket socket) : super(socket);
+ @override
Future flush() {
Uint8List bytes = consumeWriteBuffer();
// Use a sync completer to ensure that the buffer can be read immediately
// after the read buffer is set, and avoid a race condition where another
// response could overwrite the read buffer.
- var completer = new Completer<Uint8List>.sync();
+ var completer = Completer<Uint8List>.sync();
_completers.add(completer);
if (bytes.lengthInBytes > 0) {
@@ -86,6 +90,7 @@ class TClientSocketTransport extends TSocketTransport {
return completer.future;
}
+ @override
void handleIncomingMessage(Uint8List messageBytes) {
super.handleIncomingMessage(messageBytes);
@@ -103,7 +108,7 @@ class TClientSocketTransport extends TSocketTransport {
/// incoming message arrives to correlate a response to a request, using the
/// seqid.
class TAsyncClientSocketTransport extends TSocketTransport {
- static const defaultTimeout = const Duration(seconds: 30);
+ static const defaultTimeout = Duration(seconds: 30);
final Map<int, Completer<Uint8List>> _completers = {};
@@ -112,11 +117,12 @@ class TAsyncClientSocketTransport extends TSocketTransport {
final Duration responseTimeout;
TAsyncClientSocketTransport(TSocket socket, TMessageReader messageReader,
- {Duration responseTimeout: defaultTimeout})
+ {Duration responseTimeout = defaultTimeout})
: this.messageReader = messageReader,
this.responseTimeout = responseTimeout,
super(socket);
+ @override
Future flush() {
Uint8List bytes = consumeWriteBuffer();
TMessage message = messageReader.readMessage(bytes);
@@ -125,15 +131,15 @@ class TAsyncClientSocketTransport extends TSocketTransport {
// Use a sync completer to ensure that the buffer can be read immediately
// after the read buffer is set, and avoid a race condition where another
// response could overwrite the read buffer.
- var completer = new Completer<Uint8List>.sync();
+ var completer = Completer<Uint8List>.sync();
_completers[seqid] = completer;
if (responseTimeout != null) {
- new Future.delayed(responseTimeout, () {
+ Future.delayed(responseTimeout, () {
var completer = _completers.remove(seqid);
if (completer != null) {
completer.completeError(
- new TimeoutException("Response timed out.", responseTimeout));
+ TimeoutException("Response timed out.", responseTimeout));
}
});
}
@@ -143,6 +149,7 @@ class TAsyncClientSocketTransport extends TSocketTransport {
return completer.future;
}
+ @override
void handleIncomingMessage(Uint8List messageBytes) {
super.handleIncomingMessage(messageBytes);
@@ -161,14 +168,16 @@ class TServerSocketTransport extends TSocketTransport {
Stream get onIncomingMessage => _onIncomingMessageController.stream;
TServerSocketTransport(TSocket socket)
- : _onIncomingMessageController = new StreamController.broadcast(),
+ : _onIncomingMessageController = StreamController.broadcast(),
super(socket);
+ @override
Future flush() async {
Uint8List message = consumeWriteBuffer();
socket.send(message);
}
+ @override
void handleIncomingMessage(Uint8List messageBytes) {
super.handleIncomingMessage(messageBytes);
diff --git a/lib/dart/lib/src/transport/t_transport.dart b/lib/dart/lib/src/transport/t_transport.dart
index 563d5eb5a..ec9a4e80f 100644
--- a/lib/dart/lib/src/transport/t_transport.dart
+++ b/lib/dart/lib/src/transport/t_transport.dart
@@ -44,7 +44,7 @@ abstract class TTransport {
while (got < length) {
ret = read(buffer, offset + got, length - got);
if (ret <= 0) {
- throw new TTransportError(
+ throw TTransportError(
TTransportErrorType.UNKNOWN,
"Cannot read. Remote side has closed. Tried to read $length "
"bytes, but only got $got bytes.");
diff --git a/lib/dart/lib/src/transport/t_transport_factory.dart b/lib/dart/lib/src/transport/t_transport_factory.dart
index 7a10461d2..bbd95bf66 100644
--- a/lib/dart/lib/src/transport/t_transport_factory.dart
+++ b/lib/dart/lib/src/transport/t_transport_factory.dart
@@ -23,5 +23,5 @@ part of thrift;
/// Adapted from the Java version.
class TTransportFactory {
Future<TTransport> getTransport(TTransport transport) =>
- new Future.value(transport);
+ Future.value(transport);
}
diff --git a/lib/dart/lib/thrift.dart b/lib/dart/lib/thrift.dart
index c429d773c..dd89ebdc8 100644
--- a/lib/dart/lib/thrift.dart
+++ b/lib/dart/lib/thrift.dart
@@ -19,12 +19,9 @@ library thrift;
import 'dart:async';
import 'dart:collection';
-import 'dart:convert' show Utf8Codec;
-import 'dart:typed_data' show ByteData;
-import 'dart:typed_data' show Uint8List;
+import 'dart:convert' show Utf8Codec, base64;
+import 'dart:typed_data' show ByteData, Uint8List, Endian;
-import 'package:dart2_constant/convert.dart' show base64;
-import 'package:dart2_constant/typed_data.dart' show Endianness;
import 'package:fixnum/fixnum.dart';
import 'package:http/http.dart' show Client;
import 'package:logging/logging.dart';
diff --git a/lib/dart/pubspec.yaml b/lib/dart/pubspec.yaml
index e16cac384..28407e2a2 100644
--- a/lib/dart/pubspec.yaml
+++ b/lib/dart/pubspec.yaml
@@ -24,15 +24,20 @@ homepage: http://thrift.apache.org
documentation: http://thrift.apache.org
environment:
- sdk: ">=1.24.3 <3.0.0"
+ sdk: ">=2.0.0 <3.0.0"
dependencies:
- dart2_constant: ^1.0.0
fixnum: ^0.10.2
- http: ^0.11.3
+ http: ">=0.11.3 <0.13.0"
logging: ^0.11.0
dev_dependencies:
- dart_dev: ^2.0.0
- mockito: ">=2.2.2 <4.0.0"
- test: ">=0.12.30 <2.0.0"
+ build_runner: ^1.7.1
+ build_test: ^0.10.9
+ build_vm_compilers: ^1.0.3
+ build_web_compilers: ^2.7.1
+ dart_dev: ^3.0.0
+ dart_style: ^1.3.1
+ mockito: ^4.1.1
+ test: ^1.9.1
+ workiva_analysis_options: ^1.0.0 \ No newline at end of file
diff --git a/lib/dart/test/protocol/t_protocol_test.dart b/lib/dart/test/protocol/t_protocol_test.dart
index dc63dbb71..15d973cab 100644
--- a/lib/dart/test/protocol/t_protocol_test.dart
+++ b/lib/dart/test/protocol/t_protocol_test.dart
@@ -18,42 +18,42 @@
library thrift.test.transport.t_json_protocol_test;
import 'dart:async';
+import 'dart:convert' show utf8;
import 'dart:typed_data' show Uint8List;
-import 'package:dart2_constant/convert.dart' show utf8;
import 'package:test/test.dart';
import 'package:thrift/thrift.dart';
void main() {
- final message = new TMessage('my message', TMessageType.ONEWAY, 123);
+ final message = TMessage('my message', TMessageType.ONEWAY, 123);
TProtocol protocol;
Primitive getPrimitive(int tType) {
switch (tType) {
case TType.BOOL:
- return new Primitive(protocol.readBool, protocol.writeBool, false);
+ return Primitive(protocol.readBool, protocol.writeBool, false);
case TType.BYTE:
- return new Primitive(protocol.readByte, protocol.writeByte, 0);
+ return Primitive(protocol.readByte, protocol.writeByte, 0);
case TType.I16:
- return new Primitive(protocol.readI16, protocol.writeI16, 0);
+ return Primitive(protocol.readI16, protocol.writeI16, 0);
case TType.I32:
- return new Primitive(protocol.readI32, protocol.writeI32, 0);
+ return Primitive(protocol.readI32, protocol.writeI32, 0);
case TType.I64:
- return new Primitive(protocol.readI64, protocol.writeI64, 0);
+ return Primitive(protocol.readI64, protocol.writeI64, 0);
case TType.DOUBLE:
- return new Primitive(protocol.readDouble, protocol.writeDouble, 0);
+ return Primitive(protocol.readDouble, protocol.writeDouble, 0);
case TType.STRING:
- return new Primitive(protocol.readString, protocol.writeString, '');
+ return Primitive(protocol.readString, protocol.writeString, '');
default:
- throw new UnsupportedError("Unsupported TType $tType");
+ throw UnsupportedError("Unsupported TType $tType");
}
}
@@ -95,7 +95,7 @@ void main() {
});
test('Test struct', () async {
- var input = new TStruct();
+ var input = TStruct();
protocol.writeStructBegin(input);
protocol.writeStructEnd();
@@ -111,7 +111,7 @@ void main() {
});
test('Test field', () async {
- var input = new TField('my field', TType.MAP, 123);
+ var input = TField('my field', TType.MAP, 123);
protocol.writeFieldBegin(input);
protocol.writeFieldEnd();
@@ -128,7 +128,7 @@ void main() {
});
test('Test map', () async {
- var input = new TMap(TType.STRING, TType.STRUCT, 123);
+ var input = TMap(TType.STRING, TType.STRUCT, 123);
protocol.writeMapBegin(input);
protocol.writeMapEnd();
@@ -145,7 +145,7 @@ void main() {
});
test('Test list', () async {
- var input = new TList(TType.STRING, 123);
+ var input = TList(TType.STRING, 123);
protocol.writeListBegin(input);
protocol.writeListEnd();
@@ -161,7 +161,7 @@ void main() {
});
test('Test set', () async {
- var input = new TSet(TType.STRING, 123);
+ var input = TSet(TType.STRING, 123);
protocol.writeSetBegin(input);
protocol.writeSetEnd();
@@ -235,7 +235,7 @@ void main() {
});
test('Test binary', () async {
- var input = new Uint8List.fromList(new List.filled(100, 123));
+ var input = Uint8List.fromList(List.filled(100, 123));
protocol.writeBinary(input);
protocol.writeMessageEnd();
@@ -251,18 +251,18 @@ void main() {
test('Test complex struct', () async {
// {1: {10: 20}, 2: {30: 40}}
- protocol.writeStructBegin(new TStruct());
- protocol.writeFieldBegin(new TField('success', TType.MAP, 0));
- protocol.writeMapBegin(new TMap(TType.I32, TType.MAP, 2));
+ protocol.writeStructBegin(TStruct());
+ protocol.writeFieldBegin(TField('success', TType.MAP, 0));
+ protocol.writeMapBegin(TMap(TType.I32, TType.MAP, 2));
protocol.writeI32(1); // key
- protocol.writeMapBegin(new TMap(TType.I32, TType.I32, 1));
+ protocol.writeMapBegin(TMap(TType.I32, TType.I32, 1));
protocol.writeI32(10); // key
protocol.writeI32(20); // value
protocol.writeMapEnd();
protocol.writeI32(2); // key
- protocol.writeMapBegin(new TMap(TType.I32, TType.I32, 1));
+ protocol.writeMapBegin(TMap(TType.I32, TType.I32, 1));
protocol.writeI32(30); // key
protocol.writeI32(40); // value
protocol.writeMapEnd();
@@ -300,19 +300,19 @@ void main() {
test('Test nested maps and lists', () async {
// {1: [{10: 20}], 2: [{30: 40}]}
- protocol.writeMapBegin(new TMap(TType.I32, TType.LIST, 2));
+ protocol.writeMapBegin(TMap(TType.I32, TType.LIST, 2));
protocol.writeI32(1); // key
- protocol.writeListBegin(new TList(TType.MAP, 1));
- protocol.writeMapBegin(new TMap(TType.I32, TType.I32, 1));
+ protocol.writeListBegin(TList(TType.MAP, 1));
+ protocol.writeMapBegin(TMap(TType.I32, TType.I32, 1));
protocol.writeI32(10); // key
protocol.writeI32(20); // value
protocol.writeMapEnd();
protocol.writeListEnd();
protocol.writeI32(2); // key
- protocol.writeListBegin(new TList(TType.MAP, 1));
- protocol.writeMapBegin(new TMap(TType.I32, TType.I32, 1));
+ protocol.writeListBegin(TList(TType.MAP, 1));
+ protocol.writeMapBegin(TMap(TType.I32, TType.I32, 1));
protocol.writeI32(30); // key
protocol.writeI32(40); // value
protocol.writeMapEnd();
@@ -349,7 +349,7 @@ void main() {
group('JSON', () {
setUp(() {
- protocol = new TJsonProtocol(new TBufferedTransport());
+ protocol = TJsonProtocol(TBufferedTransport());
protocol.writeMessageBegin(message);
});
@@ -363,10 +363,10 @@ void main() {
UTF-16: 0xD834 0xDD1E
*/
var buffer = utf8.encode(r'"\u0001\u0e01 \ud834\udd1e"');
- var transport = new TBufferedTransport();
+ var transport = TBufferedTransport();
transport.writeAll(buffer);
- var protocol = new TJsonProtocol(transport);
+ var protocol = TJsonProtocol(transport);
await protocol.transport.flush();
@@ -380,7 +380,7 @@ void main() {
group('binary', () {
setUp(() {
- protocol = new TBinaryProtocol(new TBufferedTransport());
+ protocol = TBinaryProtocol(TBufferedTransport());
protocol.writeMessageBegin(message);
});
@@ -389,7 +389,7 @@ void main() {
group('compact', () {
setUp(() {
- protocol = new TCompactProtocol(new TBufferedTransport());
+ protocol = TCompactProtocol(TBufferedTransport());
protocol.writeMessageBegin(message);
});
diff --git a/lib/dart/test/serializer/serializer_test.dart b/lib/dart/test/serializer/serializer_test.dart
index 2f76503c4..89883cb7c 100644
--- a/lib/dart/test/serializer/serializer_test.dart
+++ b/lib/dart/test/serializer/serializer_test.dart
@@ -30,22 +30,22 @@ void main() {
TestTObject testTObject;
setUp(() {
- serializer = new TSerializer();
- deserializer = new TDeserializer();
-
- testTObject = new TestTObject();
+ serializer = TSerializer();
+ deserializer = TDeserializer();
+
+ testTObject = TestTObject();
testTObject.b = true;
testTObject.s = "TEST";
testTObject.d = 15.25;
testTObject.i = 10;
-
- var testList = new List<String>();
+
+ var testList = List<String>();
testList.add("TEST 1");
testList.add("TEST 2");
-
+
testTObject.l = testList;
});
-
+
assertNewObjectEqualsTObject(TestTObject newObject) {
expect(newObject.l, equals(testTObject.l));
expect(newObject.b, equals(testTObject.b));
@@ -53,63 +53,63 @@ void main() {
expect(newObject.d, equals(testTObject.d));
expect(newObject.s, equals(testTObject.s));
}
-
+
runWriteStringTest() {
var s = serializer.writeString(testTObject);
- var newObject = new TestTObject();
+ var newObject = TestTObject();
deserializer.readString(newObject, s);
assertNewObjectEqualsTObject(newObject);
- };
+ }
runWriteTest() {
var s = serializer.write(testTObject);
- var newObject = new TestTObject();
+ var newObject = TestTObject();
deserializer.read(newObject, s);
assertNewObjectEqualsTObject(newObject);
- };
+ }
test('JSON Protocol String', () {
- serializer.protocol = new TJsonProtocol(serializer.transport);
- deserializer.protocol = new TJsonProtocol(deserializer.transport);
-
+ serializer.protocol = TJsonProtocol(serializer.transport);
+ deserializer.protocol = TJsonProtocol(deserializer.transport);
+
runWriteStringTest();
});
test('JSON Protocol', () {
- serializer.protocol = new TJsonProtocol(serializer.transport);
- deserializer.protocol = new TJsonProtocol(deserializer.transport);
+ serializer.protocol = TJsonProtocol(serializer.transport);
+ deserializer.protocol = TJsonProtocol(deserializer.transport);
runWriteTest();
});
test('Binary Protocol String', () {
- serializer.protocol = new TBinaryProtocol(serializer.transport);
- deserializer.protocol = new TBinaryProtocol(deserializer.transport);
+ serializer.protocol = TBinaryProtocol(serializer.transport);
+ deserializer.protocol = TBinaryProtocol(deserializer.transport);
runWriteStringTest();
});
test('Binary Protocol', () {
- serializer.protocol = new TBinaryProtocol(serializer.transport);
- deserializer.protocol = new TBinaryProtocol(deserializer.transport);
+ serializer.protocol = TBinaryProtocol(serializer.transport);
+ deserializer.protocol = TBinaryProtocol(deserializer.transport);
runWriteTest();
});
test('Compact Protocol String', () {
- serializer.protocol = new TCompactProtocol(serializer.transport);
- deserializer.protocol = new TCompactProtocol(deserializer.transport);
+ serializer.protocol = TCompactProtocol(serializer.transport);
+ deserializer.protocol = TCompactProtocol(deserializer.transport);
runWriteStringTest();
});
test('Compact Protocol', () {
- serializer.protocol = new TCompactProtocol(serializer.transport);
- deserializer.protocol = new TCompactProtocol(deserializer.transport);
+ serializer.protocol = TCompactProtocol(serializer.transport);
+ deserializer.protocol = TCompactProtocol(deserializer.transport);
runWriteTest();
});
diff --git a/lib/dart/test/serializer/serializer_test_data.dart b/lib/dart/test/serializer/serializer_test_data.dart
index 3586f08fc..fc488f4e7 100644
--- a/lib/dart/test/serializer/serializer_test_data.dart
+++ b/lib/dart/test/serializer/serializer_test_data.dart
@@ -23,12 +23,12 @@ import 'package:thrift/thrift.dart';
/// TestTObject is a simple test struct
class TestTObject implements TBase {
- static final TStruct _STRUCT_DESC = new TStruct("TestTObject");
- static final TField _I_FIELD_DESC = new TField("i", TType.I32, 1);
- static final TField _D_FIELD_DESC = new TField("d", TType.DOUBLE, 2);
- static final TField _S_FIELD_DESC = new TField("s", TType.STRING, 3);
- static final TField _L_FIELD_DESC = new TField("l", TType.LIST, 4);
- static final TField _B_FIELD_DESC = new TField("b", TType.BOOL, 5);
+ static final TStruct _STRUCT_DESC = TStruct("TestTObject");
+ static final TField _I_FIELD_DESC = TField("i", TType.I32, 1);
+ static final TField _D_FIELD_DESC = TField("d", TType.DOUBLE, 2);
+ static final TField _S_FIELD_DESC = TField("s", TType.STRING, 3);
+ static final TField _L_FIELD_DESC = TField("l", TType.LIST, 4);
+ static final TField _B_FIELD_DESC = TField("b", TType.BOOL, 5);
int _i;
static const int I = 1;
@@ -45,8 +45,7 @@ class TestTObject implements TBase {
bool __isset_d = false;
bool __isset_b = false;
- TestTObject() {
- }
+ TestTObject();
// i
int get i => this._i;
@@ -116,6 +115,7 @@ class TestTObject implements TBase {
this.__isset_b = false;
}
+ @override
getFieldValue(int fieldID) {
switch (fieldID) {
case I:
@@ -129,10 +129,11 @@ class TestTObject implements TBase {
case B:
return this.b;
default:
- throw new ArgumentError("Field $fieldID doesn't exist!");
+ throw ArgumentError("Field $fieldID doesn't exist!");
}
}
+ @override
setFieldValue(int fieldID, Object value) {
switch (fieldID) {
case I:
@@ -176,11 +177,12 @@ class TestTObject implements TBase {
break;
default:
- throw new ArgumentError("Field $fieldID doesn't exist!");
+ throw ArgumentError("Field $fieldID doesn't exist!");
}
}
// Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise
+ @override
bool isSet(int fieldID) {
switch (fieldID) {
case I:
@@ -194,10 +196,11 @@ class TestTObject implements TBase {
case B:
return isSetB();
default:
- throw new ArgumentError("Field $fieldID doesn't exist!");
+ throw ArgumentError("Field $fieldID doesn't exist!");
}
}
+ @override
read(TProtocol iprot) {
TField field;
iprot.readStructBegin();
@@ -234,7 +237,7 @@ class TestTObject implements TBase {
if (field.type == TType.LIST) {
{
TList _list74 = iprot.readListBegin();
- this.l = new List<String>();
+ this.l = List<String>();
for (int _i75 = 0; _i75 < _list74.length; ++_i75) {
String _elem76;
_elem76 = iprot.readString();
@@ -266,6 +269,7 @@ class TestTObject implements TBase {
validate();
}
+ @override
write(TProtocol oprot) {
validate();
@@ -284,7 +288,7 @@ class TestTObject implements TBase {
if (this.l != null) {
oprot.writeFieldBegin(_L_FIELD_DESC);
{
- oprot.writeListBegin(new TList(TType.STRING, this.l.length));
+ oprot.writeListBegin(TList(TType.STRING, this.l.length));
for (var elem77 in this.l) {
oprot.writeString(elem77);
}
@@ -299,8 +303,9 @@ class TestTObject implements TBase {
oprot.writeStructEnd();
}
+ @override
String toString() {
- StringBuffer ret = new StringBuffer("TestTObject(");
+ StringBuffer ret = StringBuffer("TestTObject(");
ret.write("i:");
ret.write(this.i);
@@ -338,5 +343,4 @@ class TestTObject implements TBase {
// check for required fields
// check that fields of type enum have valid values
}
-
}
diff --git a/lib/dart/test/t_application_error_test.dart b/lib/dart/test/t_application_error_test.dart
index 511d8d691..848ce56a0 100644
--- a/lib/dart/test/t_application_error_test.dart
+++ b/lib/dart/test/t_application_error_test.dart
@@ -24,15 +24,14 @@ void main() {
TProtocol protocol;
setUp(() {
- protocol = new TBinaryProtocol(new TBufferedTransport());
+ protocol = TBinaryProtocol(TBufferedTransport());
});
test('Write and read an application error', () {
var expectedType = TApplicationErrorType.INTERNAL_ERROR;
var expectedMessage = 'test error message';
- TApplicationError error =
- new TApplicationError(expectedType, expectedMessage);
+ TApplicationError error = TApplicationError(expectedType, expectedMessage);
error.write(protocol);
protocol.transport.flush();
diff --git a/lib/dart/test/transport/t_framed_transport_test.dart b/lib/dart/test/transport/t_framed_transport_test.dart
index 7ab490539..d9a15a534 100644
--- a/lib/dart/test/transport/t_framed_transport_test.dart
+++ b/lib/dart/test/transport/t_framed_transport_test.dart
@@ -18,15 +18,15 @@
library thrift.test.transport.t_framed_transport_test;
import 'dart:async';
+import 'dart:convert' show utf8;
import 'dart:typed_data' show Uint8List;
-import 'package:dart2_constant/convert.dart' show utf8;
import 'package:test/test.dart';
import 'package:thrift/thrift.dart';
void main() {
group('TFramedTransport partial reads', () {
- final flushAwaitDuration = new Duration(seconds: 10);
+ final flushAwaitDuration = Duration(seconds: 10);
FakeReadOnlySocket socket;
TSocketTransport socketTransport;
@@ -34,22 +34,24 @@ void main() {
var messageAvailable;
setUp(() {
- socket = new FakeReadOnlySocket();
- socketTransport = new TClientSocketTransport(socket);
- transport = new TFramedTransport(socketTransport);
+ socket = FakeReadOnlySocket();
+ socketTransport = TClientSocketTransport(socket);
+ transport = TFramedTransport(socketTransport);
messageAvailable = false;
});
expectNoReadableBytes() {
- var readBuffer = new Uint8List(128);
+ var readBuffer = Uint8List(128);
var readBytes = transport.read(readBuffer, 0, readBuffer.lengthInBytes);
expect(readBytes, 0);
expect(messageAvailable, false);
}
- test('Test transport reads messages where header and body are sent separately', () async {
+ test(
+ 'Test transport reads messages where header and body are sent separately',
+ () async {
// buffer into which we'll read
- var readBuffer = new Uint8List(10);
+ var readBuffer = Uint8List(10);
var readBytes;
// registers for readable bytes
@@ -59,21 +61,22 @@ void main() {
});
// write header bytes
- socket.messageController.add(new Uint8List.fromList([0x00, 0x00, 0x00, 0x06]));
+ socket.messageController
+ .add(Uint8List.fromList([0x00, 0x00, 0x00, 0x06]));
// you shouldn't be able to get any bytes from the read,
// because the header has been consumed internally
expectNoReadableBytes();
// write first batch of body
- socket.messageController.add(new Uint8List.fromList(utf8.encode("He")));
+ socket.messageController.add(Uint8List.fromList(utf8.encode("He")));
// you shouldn't be able to get any bytes from the read,
// because the frame has been consumed internally
expectNoReadableBytes();
// write second batch of body
- socket.messageController.add(new Uint8List.fromList(utf8.encode("llo!")));
+ socket.messageController.add(Uint8List.fromList(utf8.encode("llo!")));
// have to wait for the flush to complete,
// because it's only then that the frame is available for reading
@@ -86,10 +89,11 @@ void main() {
expect(readBuffer.sublist(0, 6), utf8.encode("Hello!"));
});
- test('Test transport reads messages where header is sent in pieces '
- 'and body is also sent in pieces', () async {
+ test(
+ 'Test transport reads messages where header is sent in pieces '
+ 'and body is also sent in pieces', () async {
// buffer into which we'll read
- var readBuffer = new Uint8List(10);
+ var readBuffer = Uint8List(10);
var readBytes;
// registers for readable bytes
@@ -99,27 +103,27 @@ void main() {
});
// write first part of header bytes
- socket.messageController.add(new Uint8List.fromList([0x00, 0x00]));
+ socket.messageController.add(Uint8List.fromList([0x00, 0x00]));
// you shouldn't be able to get any bytes from the read
expectNoReadableBytes();
// write second part of header bytes
- socket.messageController.add(new Uint8List.fromList([0x00, 0x03]));
+ socket.messageController.add(Uint8List.fromList([0x00, 0x03]));
// you shouldn't be able to get any bytes from the read again
// because only the header was read, and there's no frame body
readBytes = expectNoReadableBytes();
// write first batch of body
- socket.messageController.add(new Uint8List.fromList(utf8.encode("H")));
+ socket.messageController.add(Uint8List.fromList(utf8.encode("H")));
// you shouldn't be able to get any bytes from the read,
// because the frame has been consumed internally
expectNoReadableBytes();
// write second batch of body
- socket.messageController.add(new Uint8List.fromList(utf8.encode("i!")));
+ socket.messageController.add(Uint8List.fromList(utf8.encode("i!")));
// have to wait for the flush to complete,
// because it's only then that the frame is available for reading
@@ -134,17 +138,18 @@ void main() {
});
}
-
-
class FakeReadOnlySocket extends TSocket {
-
- StreamController<Uint8List> messageController = new StreamController<Uint8List>(sync: true);
- StreamController<Object> errorController = new StreamController<Object>();
- StreamController<TSocketState> stateController = new StreamController<TSocketState>();
+ StreamController<Uint8List> messageController =
+ StreamController<Uint8List>(sync: true);
+ StreamController<Object> errorController = StreamController<Object>();
+ StreamController<TSocketState> stateController =
+ StreamController<TSocketState>();
@override
- Future close() {
- // noop
+ Future close() async {
+ messageController.close();
+ errorController.close();
+ stateController.close();
}
@override
@@ -163,7 +168,7 @@ class FakeReadOnlySocket extends TSocket {
Stream<TSocketState> get onState => stateController.stream;
@override
- Future open() {
+ Future open() async {
// noop
}
@@ -172,4 +177,3 @@ class FakeReadOnlySocket extends TSocket {
// noop
}
}
-
diff --git a/lib/dart/test/transport/t_http_transport_test.dart b/lib/dart/test/transport/t_http_transport_test.dart
index 03ccede9a..13f0ee98a 100644
--- a/lib/dart/test/transport/t_http_transport_test.dart
+++ b/lib/dart/test/transport/t_http_transport_test.dart
@@ -20,9 +20,9 @@ library thrift.test.transport.t_socket_transport_test;
import 'dart:async';
import 'dart:convert' show Encoding;
import 'dart:convert' show Utf8Codec;
+import 'dart:convert' show base64;
import 'dart:typed_data' show Uint8List;
-import 'package:dart2_constant/convert.dart' show base64;
import 'package:http/http.dart' show BaseRequest;
import 'package:http/http.dart' show Client;
import 'package:http/http.dart' show Response;
@@ -31,16 +31,16 @@ import 'package:test/test.dart';
import 'package:thrift/thrift.dart';
void main() {
- const utf8Codec = const Utf8Codec();
+ const utf8Codec = Utf8Codec();
group('THttpClientTransport', () {
FakeHttpClient client;
THttpClientTransport transport;
setUp(() {
- client = new FakeHttpClient(sync: false);
- var config = new THttpConfig(Uri.parse('http://localhost'), {});
- transport = new THttpClientTransport(client, config);
+ client = FakeHttpClient(sync: false);
+ var config = THttpConfig(Uri.parse('http://localhost'), {});
+ transport = THttpClientTransport(client, config);
});
test('Test transport sends body', () async {
@@ -69,7 +69,7 @@ void main() {
expect(transport.hasReadData, isTrue);
- var buffer = new Uint8List(expectedBytes.length);
+ var buffer = Uint8List(expectedBytes.length);
transport.readAll(buffer, 0, expectedBytes.length);
var bufferText = utf8Codec.decode(buffer);
@@ -82,9 +82,9 @@ void main() {
THttpClientTransport transport;
setUp(() {
- client = new FakeHttpClient(sync: true);
- var config = new THttpConfig(Uri.parse('http://localhost'), {});
- transport = new THttpClientTransport(client, config);
+ client = FakeHttpClient(sync: true);
+ var config = THttpConfig(Uri.parse('http://localhost'), {});
+ transport = THttpClientTransport(client, config);
});
test('Test read correct buffer after flush', () async {
@@ -97,7 +97,7 @@ void main() {
client.postResponse = base64.encode(expectedBytes);
Future responseReady = transport.flush().then((_) {
- var buffer = new Uint8List(expectedBytes.length);
+ var buffer = Uint8List(expectedBytes.length);
transport.readAll(buffer, 0, expectedBytes.length);
bufferText = utf8Codec.decode(buffer);
});
@@ -120,45 +120,55 @@ class FakeHttpClient implements Client {
final bool sync;
- FakeHttpClient({this.sync: false});
+ FakeHttpClient({this.sync = false});
+ @override
Future<Response> post(url,
{Map<String, String> headers, body, Encoding encoding}) {
postRequest = body;
- var response = new Response(postResponse, 200);
+ var response = Response(postResponse, 200);
if (sync) {
- return new Future.sync(() => response);
+ return Future.sync(() => response);
} else {
- return new Future.value(response);
+ return Future.value(response);
}
}
+ @override
Future<Response> head(url, {Map<String, String> headers}) =>
- throw new UnimplementedError();
+ throw UnimplementedError();
+ @override
Future<Response> get(url, {Map<String, String> headers}) =>
- throw new UnimplementedError();
+ throw UnimplementedError();
+ @override
Future<Response> put(url,
{Map<String, String> headers, body, Encoding encoding}) =>
- throw new UnimplementedError();
+ throw UnimplementedError();
+ @override
Future<Response> patch(url,
{Map<String, String> headers, body, Encoding encoding}) =>
- throw new UnimplementedError();
+ throw UnimplementedError();
+ @override
Future<Response> delete(url, {Map<String, String> headers}) =>
- throw new UnimplementedError();
+ throw UnimplementedError();
+ @override
Future<String> read(url, {Map<String, String> headers}) =>
- throw new UnimplementedError();
+ throw UnimplementedError();
+ @override
Future<Uint8List> readBytes(url, {Map<String, String> headers}) =>
- throw new UnimplementedError();
+ throw UnimplementedError();
+ @override
Future<StreamedResponse> send(BaseRequest request) =>
- throw new UnimplementedError();
+ throw UnimplementedError();
- void close() => throw new UnimplementedError();
+ @override
+ void close() => throw UnimplementedError();
}
diff --git a/lib/dart/test/transport/t_socket_transport_test.dart b/lib/dart/test/transport/t_socket_transport_test.dart
index 90bffbe54..d46f5ede4 100644
--- a/lib/dart/test/transport/t_socket_transport_test.dart
+++ b/lib/dart/test/transport/t_socket_transport_test.dart
@@ -18,24 +18,22 @@
library thrift.test.transport.t_socket_transport_test;
import 'dart:async';
-import 'dart:convert' show Utf8Codec;
+import 'dart:convert' show Utf8Codec, base64;
import 'dart:typed_data' show Uint8List;
-import 'package:dart2_constant/convert.dart' show base64;
-import 'package:dart2_constant/core.dart' as core;
import 'package:mockito/mockito.dart';
import 'package:test/test.dart';
import 'package:thrift/thrift.dart';
void main() {
- const utf8Codec = const Utf8Codec();
+ const utf8Codec = Utf8Codec();
final requestText = 'my test request';
- final requestBytes = new Uint8List.fromList(utf8Codec.encode(requestText));
+ final requestBytes = Uint8List.fromList(utf8Codec.encode(requestText));
final requestBase64 = base64.encode(requestBytes);
final responseText = 'response 1';
- final responseBytes = new Uint8List.fromList(utf8Codec.encode(responseText));
+ final responseBytes = Uint8List.fromList(utf8Codec.encode(responseText));
final responseBase64 = base64.encode(responseBytes);
final framedResponseBase64 = base64.encode(_getFramedResponse(responseBytes));
@@ -45,9 +43,9 @@ void main() {
TTransport transport;
setUp(() async {
- socket = new FakeSocket(sync: false);
+ socket = FakeSocket(sync: false);
await socket.open();
- transport = new TClientSocketTransport(socket);
+ transport = TClientSocketTransport(socket);
await transport.open();
transport.writeAll(requestBytes);
});
@@ -58,7 +56,7 @@ void main() {
Future responseReady = transport.flush();
// allow microtask events to finish
- await new Future.value();
+ await Future.value();
expect(socket.sendPayload, isNotNull);
expect(socket.sendPayload, requestBytes);
@@ -67,23 +65,23 @@ void main() {
socket.receiveFakeMessage(responseBase64);
await responseReady;
- var buffer = new Uint8List(responseBytes.length);
+ var buffer = Uint8List(responseBytes.length);
transport.readAll(buffer, 0, responseBytes.length);
var bufferText = utf8Codec.decode(buffer);
expect(bufferText, responseText);
});
- }, timeout: new Timeout(new Duration(seconds: 1)));
+ }, timeout: Timeout(Duration(seconds: 1)));
group('TClientSocketTransport with FramedTransport', () {
FakeSocket socket;
TTransport transport;
setUp(() async {
- socket = new FakeSocket(sync: true);
+ socket = FakeSocket(sync: true);
await socket.open();
- transport = new TFramedTransport(new TClientSocketTransport(socket));
+ transport = TFramedTransport(TClientSocketTransport(socket));
await transport.open();
transport.writeAll(requestBytes);
});
@@ -92,7 +90,7 @@ void main() {
String bufferText;
Future responseReady = transport.flush().then((_) {
- var buffer = new Uint8List(responseBytes.length);
+ var buffer = Uint8List(responseBytes.length);
transport.readAll(buffer, 0, responseBytes.length);
bufferText = utf8Codec.decode(buffer);
});
@@ -103,7 +101,7 @@ void main() {
await responseReady;
expect(bufferText, responseText);
});
- }, timeout: new Timeout(new Duration(seconds: 1)));
+ }, timeout: Timeout(Duration(seconds: 1)));
group('TAsyncClientSocketTransport', () {
FakeSocket socket;
@@ -111,14 +109,14 @@ void main() {
TTransport transport;
setUp(() async {
- socket = new FakeSocket(sync: true);
+ socket = FakeSocket(sync: true);
await socket.open();
- protocolFactory = new FakeProtocolFactory();
- protocolFactory.message = new TMessage('foo', TMessageType.CALL, 123);
- transport = new TAsyncClientSocketTransport(
- socket, new TMessageReader(protocolFactory),
- responseTimeout: core.Duration.zero);
+ protocolFactory = FakeProtocolFactory();
+ protocolFactory.message = TMessage('foo', TMessageType.CALL, 123);
+ transport = TAsyncClientSocketTransport(
+ socket, TMessageReader(protocolFactory),
+ responseTimeout: Duration.zero);
await transport.open();
transport.writeAll(requestBytes);
});
@@ -127,21 +125,20 @@ void main() {
String bufferText;
Future responseReady = transport.flush().then((_) {
- var buffer = new Uint8List(responseBytes.length);
+ var buffer = Uint8List(responseBytes.length);
transport.readAll(buffer, 0, responseBytes.length);
bufferText = utf8Codec.decode(buffer);
});
// simulate a response
- protocolFactory.message = new TMessage('foo', TMessageType.REPLY, 123);
+ protocolFactory.message = TMessage('foo', TMessageType.REPLY, 123);
socket.receiveFakeMessage(responseBase64);
// simulate a second response
var response2Text = 'response 2';
- var response2Bytes =
- new Uint8List.fromList(utf8Codec.encode(response2Text));
+ var response2Bytes = Uint8List.fromList(utf8Codec.encode(response2Text));
var response2Base64 = base64.encode(response2Bytes);
- protocolFactory.message = new TMessage('foo2', TMessageType.REPLY, 124);
+ protocolFactory.message = TMessage('foo2', TMessageType.REPLY, 124);
socket.receiveFakeMessage(response2Base64);
await responseReady;
@@ -150,9 +147,9 @@ void main() {
test('Test response timeout', () async {
Future responseReady = transport.flush();
- expect(responseReady, throwsA(new isInstanceOf<TimeoutException>()));
+ expect(responseReady, throwsA(isA<TimeoutException>()));
});
- }, timeout: new Timeout(new Duration(seconds: 1)));
+ }, timeout: Timeout(Duration(seconds: 1)));
group('TAsyncClientSocketTransport with TFramedTransport', () {
FakeSocket socket;
@@ -160,17 +157,17 @@ void main() {
TTransport transport;
setUp(() async {
- socket = new FakeSocket(sync: true);
+ socket = FakeSocket(sync: true);
await socket.open();
- protocolFactory = new FakeProtocolFactory();
- protocolFactory.message = new TMessage('foo', TMessageType.CALL, 123);
- var messageReader = new TMessageReader(protocolFactory,
+ protocolFactory = FakeProtocolFactory();
+ protocolFactory.message = TMessage('foo', TMessageType.CALL, 123);
+ var messageReader = TMessageReader(protocolFactory,
byteOffset: TFramedTransport.headerByteCount);
- transport = new TFramedTransport(new TAsyncClientSocketTransport(
+ transport = TFramedTransport(TAsyncClientSocketTransport(
socket, messageReader,
- responseTimeout: core.Duration.zero));
+ responseTimeout: Duration.zero));
await transport.open();
transport.writeAll(requestBytes);
});
@@ -179,37 +176,37 @@ void main() {
String bufferText;
Future responseReady = transport.flush().then((_) {
- var buffer = new Uint8List(responseBytes.length);
+ var buffer = Uint8List(responseBytes.length);
transport.readAll(buffer, 0, responseBytes.length);
bufferText = utf8Codec.decode(buffer);
});
// simulate a response
- protocolFactory.message = new TMessage('foo', TMessageType.REPLY, 123);
+ protocolFactory.message = TMessage('foo', TMessageType.REPLY, 123);
socket.receiveFakeMessage(framedResponseBase64);
await responseReady;
expect(bufferText, responseText);
});
- }, timeout: new Timeout(new Duration(seconds: 1)));
+ }, timeout: Timeout(Duration(seconds: 1)));
group('TServerTransport', () {
test('Test server transport listens to socket', () async {
- var socket = new FakeSocket();
+ var socket = FakeSocket();
await socket.open();
expect(socket.isOpen, isTrue);
- var transport = new TServerSocketTransport(socket);
+ var transport = TServerSocketTransport(socket);
expect(transport.hasReadData, isFalse);
socket.receiveFakeMessage(requestBase64);
// allow microtask events to finish
- await new Future.value();
+ await Future.value();
expect(transport.hasReadData, isTrue);
- var buffer = new Uint8List(requestBytes.length);
+ var buffer = Uint8List(requestBytes.length);
transport.readAll(buffer, 0, requestBytes.length);
var bufferText = utf8Codec.decode(buffer);
@@ -217,10 +214,10 @@ void main() {
});
test('Test server sending data over transport', () async {
- var socket = new FakeSocket();
+ var socket = FakeSocket();
await socket.open();
- var transport = new TServerSocketTransport(socket);
+ var transport = TServerSocketTransport(socket);
transport.writeAll(responseBytes);
expect(socket.sendPayload, isNull);
@@ -228,40 +225,47 @@ void main() {
transport.flush();
// allow microtask events to finish
- await new Future.value();
+ await Future.value();
expect(socket.sendPayload, isNotNull);
expect(socket.sendPayload, responseBytes);
});
- }, timeout: new Timeout(new Duration(seconds: 1)));
+ }, timeout: Timeout(Duration(seconds: 1)));
}
class FakeSocket extends TSocket {
final StreamController<TSocketState> _onStateController;
+ @override
Stream<TSocketState> get onState => _onStateController.stream;
final StreamController<Object> _onErrorController;
+ @override
Stream<Object> get onError => _onErrorController.stream;
final StreamController<Uint8List> _onMessageController;
+ @override
Stream<Uint8List> get onMessage => _onMessageController.stream;
- FakeSocket({bool sync: false})
- : _onStateController = new StreamController.broadcast(sync: sync),
- _onErrorController = new StreamController.broadcast(sync: sync),
- _onMessageController = new StreamController.broadcast(sync: sync);
+ FakeSocket({bool sync = false})
+ : _onStateController = StreamController.broadcast(sync: sync),
+ _onErrorController = StreamController.broadcast(sync: sync),
+ _onMessageController = StreamController.broadcast(sync: sync);
bool _isOpen;
+ @override
bool get isOpen => _isOpen;
+ @override
bool get isClosed => !isOpen;
+ @override
Future open() async {
_isOpen = true;
_onStateController.add(TSocketState.OPEN);
}
+ @override
Future close() async {
_isOpen = false;
_onStateController.add(TSocketState.CLOSED);
@@ -270,16 +274,17 @@ class FakeSocket extends TSocket {
Uint8List _sendPayload;
Uint8List get sendPayload => _sendPayload;
+ @override
void send(Uint8List data) {
- if (!isOpen) throw new StateError('The socket is not open');
+ if (!isOpen) throw StateError('The socket is not open');
_sendPayload = data;
}
void receiveFakeMessage(String base64text) {
- if (!isOpen) throw new StateError('The socket is not open');
+ if (!isOpen) throw StateError('The socket is not open');
- var message = new Uint8List.fromList(base64.decode(base64text));
+ var message = Uint8List.fromList(base64.decode(base64text));
_onMessageController.add(message);
}
}
@@ -289,7 +294,8 @@ class FakeProtocolFactory implements TProtocolFactory {
TMessage message;
- getProtocol(TTransport transport) => new FakeProtocol(message);
+ @override
+ getProtocol(TTransport transport) => FakeProtocol(message);
}
class FakeProtocol extends Mock implements TProtocol {
@@ -297,12 +303,13 @@ class FakeProtocol extends Mock implements TProtocol {
TMessage _message;
+ @override
readMessageBegin() => _message;
}
Uint8List _getFramedResponse(Uint8List responseBytes) {
var byteOffset = TFramedTransport.headerByteCount;
- var response = new Uint8List(byteOffset + responseBytes.length);
+ var response = Uint8List(byteOffset + responseBytes.length);
response.buffer.asByteData().setInt32(0, responseBytes.length);
response.setAll(byteOffset, responseBytes);
diff --git a/lib/dart/test/transport/t_transport_test.dart b/lib/dart/test/transport/t_transport_test.dart
index 0bb381ac8..4758593a9 100644
--- a/lib/dart/test/transport/t_transport_test.dart
+++ b/lib/dart/test/transport/t_transport_test.dart
@@ -25,14 +25,14 @@ void main() {
group('TTransportFactory', () {
test('transport is returned from base factory', () async {
TTransport result;
- TTransport transport = null;
+ TTransport transport;
- var factory = new TTransportFactory();
+ var factory = TTransportFactory();
result = await factory.getTransport(transport);
expect(result, isNull);
- transport = new TBufferedTransport();
+ transport = TBufferedTransport();
result = await factory.getTransport(transport);
expect(result, transport);
diff --git a/lib/dart/tool/dev.dart b/lib/dart/tool/dev.dart
deleted file mode 100644
index 27f8b8fcf..000000000
--- a/lib/dart/tool/dev.dart
+++ /dev/null
@@ -1,33 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-library tool.dev;
-
-import 'package:dart_dev/dart_dev.dart' show dev, config;
-
-main(List<String> args) async {
- // https://github.com/Workiva/dart_dev
-
- var directories = ['lib/', 'test/', 'tool/'];
- config.analyze.entryPoints = directories;
- config.format.directories = directories;
- config.copyLicense
- ..licensePath = 'LICENSE_HEADER'
- ..directories = directories;
-
- await dev(args);
-}