Revert "Revert "Send DAP events through DDS"" - only check for event handler when DDS URI is also set.

Original change reverted due to test failure: https://github.com/dart-lang/sdk/issues/43743#issuecomment-1601278402

This reverts commit 02b10e1321.

Change-Id: Idb2cbffe18342c76d0cc062e5855c10a6df0e8f1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310780
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Helin Shiah <helinx@google.com>
This commit is contained in:
Helin Shiah 2023-06-22 21:43:22 +00:00 committed by Commit Queue
parent e56ef707eb
commit 5b3f7990e8
12 changed files with 62 additions and 12 deletions

View file

@ -6,6 +6,7 @@
- [DAP] Fixed an issue that could leave breakpoints unresolved when adding/removing other breakpoints in a file. - [DAP] Fixed an issue that could leave breakpoints unresolved when adding/removing other breakpoints in a file.
- Fixed a bug that was preventing clients from receiving `IsolateReload` events - Fixed a bug that was preventing clients from receiving `IsolateReload` events
(see https://dartbug.com/49491). (see https://dartbug.com/49491).
- Added notifications for DAP events.
# 2.9.0 # 2.9.0
- Updated DDS protocol to version 1.6. - Updated DDS protocol to version 1.6.

View file

@ -45,6 +45,8 @@ class DdsHostedAdapter extends DartDebugAdapter<DartLaunchRequestArguments,
@override @override
bool get terminateOnVmServiceClose => true; bool get terminateOnVmServiceClose => true;
final _dapEventsController = StreamController<Event>();
@override @override
Future<void> debuggerConnected(vm.VM vmInfo) async {} Future<void> debuggerConnected(vm.VM vmInfo) async {}
@ -121,4 +123,13 @@ class DdsHostedAdapter extends DartDebugAdapter<DartLaunchRequestArguments,
throw potentialException; throw potentialException;
} }
} }
@override
void sendEventToChannel(Event event) {
_dapEventsController.add(event);
}
void setEventHandler(void Function(Event) eventHandler) {
_dapEventsController.stream.listen(eventHandler);
}
} }

View file

@ -205,6 +205,10 @@ abstract class BaseDebugAdapter<TLaunchArgs extends LaunchRequestArguments,
event: eventType ?? eventTypes[body.runtimeType]!, event: eventType ?? eventTypes[body.runtimeType]!,
body: body, body: body,
); );
sendEventToChannel(event);
}
void sendEventToChannel(Event event) {
_channel.sendEvent(event); _channel.sendEvent(event);
} }

View file

@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file. // BSD-style license that can be found in the LICENSE file.
import 'dart:async'; import 'dart:async';
import 'package:dds_service_extensions/dap.dart';
import 'package:json_rpc_2/json_rpc_2.dart' as json_rpc; import 'package:json_rpc_2/json_rpc_2.dart' as json_rpc;
import '../dap.dart'; import '../dap.dart';
@ -41,8 +43,20 @@ class DapHandler {
}; };
} }
_handleEvent(Event event) {
dds.streamManager.streamNotify(DapEventStreams.kDAP, {
'streamId': DapEventStreams.kDAP,
'event': {
'kind': DapEventKind.kDAPEvent,
'timestamp': DateTime.now().millisecondsSinceEpoch,
'dapData': event,
},
});
}
Future<void> _startAdapter(DdsHostedAdapter adapter) async { Future<void> _startAdapter(DdsHostedAdapter adapter) async {
adapter.ddsUri = dds.uri; adapter.ddsUri = dds.uri;
adapter.setEventHandler(_handleEvent);
// TODO(helin24): Most likely we'll want the client to do these // TODO(helin24): Most likely we'll want the client to do these
// initialization steps so that clients can differentiate capabilities. This // initialization steps so that clients can differentiate capabilities. This

View file

@ -13,7 +13,7 @@ dependencies:
async: ^2.4.1 async: ^2.4.1
browser_launcher: ^1.0.0 browser_launcher: ^1.0.0
collection: ^1.15.0 collection: ^1.15.0
dds_service_extensions: ^1.3.0 dds_service_extensions: ^1.6.0
dap: ^1.1.0 dap: ^1.1.0
devtools_shared: ^2.14.1 devtools_shared: ^2.14.1
http_multi_server: ^3.0.0 http_multi_server: ^3.0.0
@ -27,7 +27,7 @@ dependencies:
sse: ^4.0.0 sse: ^4.0.0
stack_trace: ^1.10.0 stack_trace: ^1.10.0
stream_channel: ^2.0.0 stream_channel: ^2.0.0
vm_service: '>=11.0.0 <12.0.0' vm_service: '>=11.7.2 <12.0.0'
web_socket_channel: ^2.0.0 web_socket_channel: ^2.0.0
# We use 'any' version constraints here as we get our package versions from # We use 'any' version constraints here as we get our package versions from

View file

@ -7,7 +7,7 @@ import 'dart:io';
import 'package:dap/dap.dart'; import 'package:dap/dap.dart';
import 'package:dds/dds.dart'; import 'package:dds/dds.dart';
import 'package:dds_service_extensions/src/dap.dart'; import 'package:dds_service_extensions/dap.dart';
import 'package:test/test.dart'; import 'package:test/test.dart';
import 'package:vm_service/vm_service_io.dart'; import 'package:vm_service/vm_service_io.dart';

View file

@ -1,3 +1,6 @@
## 1.6.0
- Made DAP extensions methods accessible in lib.
## 1.5.0 ## 1.5.0
- Added `DdsExtension.postEvent`. - Added `DdsExtension.postEvent`.

View file

@ -29,6 +29,8 @@ extension DapExtension on vm.VmService {
vm.addTypeFactory('DapResponse', DapResponse.parse); vm.addTypeFactory('DapResponse', DapResponse.parse);
_factoriesRegistered = true; _factoriesRegistered = true;
} }
Stream<vm.Event> get onDAPEvent => onEvent(DapEventStreams.kDAP);
} }
class DapResponse extends vm.Response { class DapResponse extends vm.Response {
@ -50,3 +52,19 @@ class DapResponse extends vm.Response {
final dap.Response dapResponse; final dap.Response dapResponse;
} }
extension DapEvents on vm.Event {
dap.Event get dapData {
assert(json != null);
return dap.Event.fromJson(json!['dapData']);
}
}
abstract class DapEventStreams extends vm.EventStreams {
static const String kDAP = 'DAP';
}
abstract class DapEventKind extends vm.EventKind {
/// Notification that a DAP event occurred.
static const String kDAPEvent = 'DAPEvent';
}

View file

@ -1,5 +1,5 @@
name: dds_service_extensions name: dds_service_extensions
version: 1.5.0 version: 1.6.0
description: >- description: >-
Extension methods for `package:vm_service`, used to make requests a Extension methods for `package:vm_service`, used to make requests a
Dart Development Service (DDS) instance. Dart Development Service (DDS) instance.
@ -11,7 +11,7 @@ environment:
dependencies: dependencies:
async: ^2.4.1 async: ^2.4.1
dap: ^1.0.0 dap: ^1.0.0
vm_service: ^11.0.0 vm_service: ^11.7.2
# We use 'any' version constraints here as we get our package versions from # We use 'any' version constraints here as we get our package versions from
# the dart-lang/sdk repo's DEPS file. Note that this is a special case; the # the dart-lang/sdk repo's DEPS file. Note that this is a special case; the

View file

@ -1,3 +1,6 @@
## 11.7.2
- Make Event classes abstract to permit `dap` event stream extensions.
## 11.7.1 ## 11.7.1
- Expose RPC error codes that were defined in `package:dds`. - Expose RPC error codes that were defined in `package:dds`.

View file

@ -2834,9 +2834,7 @@ class ErrorKind {
} }
/// An enum of available event streams. /// An enum of available event streams.
class EventStreams { abstract class EventStreams {
EventStreams._();
static const String kVM = 'VM'; static const String kVM = 'VM';
static const String kIsolate = 'Isolate'; static const String kIsolate = 'Isolate';
static const String kDebug = 'Debug'; static const String kDebug = 'Debug';
@ -2853,9 +2851,7 @@ class EventStreams {
/// Adding new values to `EventKind` is considered a backwards compatible /// Adding new values to `EventKind` is considered a backwards compatible
/// change. Clients should ignore unrecognized events. /// change. Clients should ignore unrecognized events.
class EventKind { abstract class EventKind {
EventKind._();
/// Notification that VM identifying information has changed. Currently used /// Notification that VM identifying information has changed. Currently used
/// to notify of changes to the VM debugging name via setVMName. /// to notify of changes to the VM debugging name via setVMName.
static const String kVMUpdate = 'VMUpdate'; static const String kVMUpdate = 'VMUpdate';

View file

@ -1,5 +1,5 @@
name: vm_service name: vm_service
version: 11.7.1 version: 11.7.2
description: >- description: >-
A library to communicate with a service implementing the Dart VM A library to communicate with a service implementing the Dart VM
service protocol. service protocol.