Unverified Commit 3572a7e8 authored by Zachary Anderson's avatar Zachary Anderson Committed by GitHub

Revert "feat: migrate base/dds.dart to null-safety (#88015)" (#88367)

parent 9e3de9a3
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'dart:async'; import 'dart:async';
import 'package:dds/dds.dart' as dds; import 'package:dds/dds.dart' as dds;
...@@ -22,10 +24,10 @@ Future<dds.DartDevelopmentService> Function( ...@@ -22,10 +24,10 @@ Future<dds.DartDevelopmentService> Function(
/// Helper class to launch a [dds.DartDevelopmentService]. Allows for us to /// Helper class to launch a [dds.DartDevelopmentService]. Allows for us to
/// mock out this functionality for testing purposes. /// mock out this functionality for testing purposes.
class DartDevelopmentService { class DartDevelopmentService {
dds.DartDevelopmentService? _ddsInstance; dds.DartDevelopmentService _ddsInstance;
Uri? get uri => _ddsInstance?.uri ?? _existingDdsUri; Uri get uri => _ddsInstance?.uri ?? _existingDdsUri;
Uri? _existingDdsUri; Uri _existingDdsUri;
Future<void> get done => _completer.future; Future<void> get done => _completer.future;
final Completer<void> _completer = Completer<void>(); final Completer<void> _completer = Completer<void>();
...@@ -35,7 +37,7 @@ class DartDevelopmentService { ...@@ -35,7 +37,7 @@ class DartDevelopmentService {
int hostPort, int hostPort,
bool ipv6, bool ipv6,
bool disableServiceAuthCodes, { bool disableServiceAuthCodes, {
required Logger logger, @required Logger logger,
}) async { }) async {
final Uri ddsUri = Uri( final Uri ddsUri = Uri(
scheme: 'http', scheme: 'http',
...@@ -43,7 +45,7 @@ class DartDevelopmentService { ...@@ -43,7 +45,7 @@ class DartDevelopmentService {
io.InternetAddress.loopbackIPv6 : io.InternetAddress.loopbackIPv6 :
io.InternetAddress.loopbackIPv4 io.InternetAddress.loopbackIPv4
).host, ).host,
port: hostPort, port: hostPort ?? 0,
); );
logger.printTrace( logger.printTrace(
'Launching a Dart Developer Service (DDS) instance at $ddsUri, ' 'Launching a Dart Developer Service (DDS) instance at $ddsUri, '
...@@ -56,12 +58,12 @@ class DartDevelopmentService { ...@@ -56,12 +58,12 @@ class DartDevelopmentService {
enableAuthCodes: !disableServiceAuthCodes, enableAuthCodes: !disableServiceAuthCodes,
ipv6: ipv6, ipv6: ipv6,
); );
unawaited(_ddsInstance?.done.whenComplete(() { unawaited(_ddsInstance.done.whenComplete(() {
if (!_completer.isCompleted) { if (!_completer.isCompleted) {
_completer.complete(); _completer.complete();
} }
})); }));
logger.printTrace('DDS is listening at ${_ddsInstance?.uri}.'); logger.printTrace('DDS is listening at ${_ddsInstance.uri}.');
} on dds.DartDevelopmentServiceException catch (e) { } on dds.DartDevelopmentServiceException catch (e) {
logger.printTrace('Warning: Failed to start DDS: ${e.message}'); logger.printTrace('Warning: Failed to start DDS: ${e.message}');
if (e.errorCode == dds.DartDevelopmentServiceException.existingDdsInstanceError) { if (e.errorCode == dds.DartDevelopmentServiceException.existingDdsInstanceError) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment