on master help sign in
dap-basic: parse stop event
commitb3be6b269aaf8b81d74ca4f0001254d8a17a6c76 authorDmitry Sharshakov <d3dx12.xx@gmail.com> dateSat 14 Aug 2021, 09:25 (5 years ago) parent0777948
3 files changed+17−3
helix-dap/examples/dap-basic.rs+4−2 helix-dap/src/client.rs+12 helix-dap/src/lib.rs+1−1
helix-dap/examples/dap-basic.rs+4−2
@@ -1,4 +1,4 @@
1−use helix_dap::{Client, Event, OutputEventBody, Result, SourceBreakpoint};
1+use helix_dap::{Client, Event, OutputEventBody, Result, SourceBreakpoint, StoppedEventBody};
22use serde::{Deserialize, Serialize};
33use serde_json::from_value;
44use tokio::sync::mpsc::Receiver;
@@ -75,7 +75,9 @@ pub async fn main() -> Result<()> {
7575
7676 println!("configurationDone: {:?}", client.configuration_done().await);
7777
78− println!("stopped: {:?}", stopped_event.recv().await);
78+ let stop: StoppedEventBody =
79+ from_value(stopped_event.recv().await.unwrap().body.unwrap()).unwrap();
80+ println!("stopped: {:?}", stop);
7981
8082 println!("threads: {:#?}", client.threads().await);
8183 let bt = client.stack_trace(1).await.expect("expected stack trace");
helix-dap/src/client.rs+12
@@ -267,6 +267,18 @@ pub struct OutputEventBody {
267267 pub data: Option<Value>,
268268}
269269
270+#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)]
271+#[serde(rename_all = "camelCase")]
272+pub struct StoppedEventBody {
273+ pub reason: String,
274+ pub description: Option<String>,
275+ pub thread_id: Option<usize>,
276+ pub preserve_focus_hint: Option<bool>,
277+ pub text: Option<String>,
278+ pub all_threads_stopped: Option<bool>,
279+ pub hit_breakpoint_ids: Option<Vec<usize>>,
280+}
281+
270282#[derive(Debug)]
271283pub struct Client {
272284 id: usize,
helix-dap/src/lib.rs+1−1
@@ -1,7 +1,7 @@
11mod client;
22mod transport;
33
4−pub use client::{Breakpoint, Client, OutputEventBody, SourceBreakpoint};
4+pub use client::{Breakpoint, Client, OutputEventBody, SourceBreakpoint, StoppedEventBody};
55pub use transport::{Event, Payload, Request, Response, Transport};
66
77use thiserror::Error;