Commit Graph

12 Commits (b1ee4ab5c6e7c257e59d3d5eff726d60e2e754f6)

Author SHA1 Message Date
Michael Davis fec5101a41
DAP: Refactor handling of Event and Request protocol types
This change refactors the DAP `Event` type, the `helix_dap` module and
the `helix_dap::transport` module to be closer to the equivalent
implementations in `helix_lsp`. The DAP `Event` type is similar to LSP's
`Notification` so this change rewrites the enum as a trait which is
implemented by empty types (for example `enum Initialized {}`).

`Event` is then reintroduced as an enum in `helix_dap` with a helper
function to convert from the `Event` as the transport knows it. By
separating the definitions of `Event` between lib and transport, we can
handle incoming events which are not known to our `Event` enum. For
example debugpy sends `"debugpySockets"` which is unknown. With this
change, unknown events are discarded with an info-level log message.

The `Request` type was already a trait but did not have an enum with the
known values. This change also introduces a `helix_dap::Request` enum
similar to `helix_dap::Event`. This resolves a TODO comment about
avoiding `unwrap` when parsing the request's arguments.
2025-01-27 15:27:35 -05:00
Michael Davis cb25d13028 Improve error handling for `which::which` failures
Co-authored-by: Pascal Kuthe <pascalkuthe@pm.me>
2024-01-24 15:47:49 +09:00
Filip Dutescu e3765ac6d2
feat(dap): send Disconnect if Terminated event received (#5532)
Send a `Disconnect` DAP request if the `Terminated` event is received.
According to the specification, if the debugging session was started by
as `launch`, the debuggee should be terminated alongside the session. If
instead the session was started as `attach`, it should not be disposed of.

This default behaviour can be overriden if the `supportTerminateDebuggee`
capability is supported by the adapter, through the `Disconnect` request
`terminateDebuggee` argument, as described in
[the specification][discon-spec].

This also implies saving the starting command for a debug sessions, in
order to decide which behaviour should be used, as well as validating the
capabilities of the adapter, in order to decide what the disconnect should
do.

An additional change made is handling of the `Exited` event, showing a
message if the exit code is different than `0`, for the user to be aware
off the termination failure.

[discon-spec]: https://microsoft.github.io/debug-adapter-protocol/specification#Requests_Disconnect

Closes: #4674

Signed-off-by: Filip Dutescu <filip.dutescu@gmail.com>
2023-02-20 13:00:00 +09:00
xiaoma20082008 ce0837dbb7
DAP: Add request ID to request timeout message (#6018)
This improves error logging for dap requests. Without the ID
it's hard to know which request is the one that timed out.
2023-02-16 10:21:12 -06:00
Blaž Hrastnik 83a8167402 Invert core -> dap dependency 2021-10-17 13:58:11 +09:00
Dmitry Sharshakov d943a51e3e
editor: add Node.js debugger 2021-09-26 21:36:06 +03:00
Blaž Hrastnik 28658836ee Add more event types, simplify event decoding 2021-08-22 16:05:12 +09:00
Blaž Hrastnik 3a9e1c305b Refactor types, add a Request trait 2021-08-20 13:43:54 +09:00
Blaž Hrastnik 2d1ae2e44b dap: Split types off into types.rs 2021-08-20 13:43:54 +09:00
Dmitry Sharshakov b3be6b269a dap-basic: parse stop event 2021-08-20 13:43:54 +09:00
Dmitry Sharshakov 09390be6a5 dap-basic: handle output events 2021-08-20 13:43:54 +09:00
Dmitry Sharshakov 0f6e81b85b Initial debug adapter protocol implementation 2021-08-20 13:43:54 +09:00