dap-basic: parse stop event

pull/574/head
Dmitry Sharshakov 3 years ago committed by Blaž Hrastnik
parent 0777948fc0
commit b3be6b269a

@ -1,4 +1,4 @@
use helix_dap::{Client, Event, OutputEventBody, Result, SourceBreakpoint}; use helix_dap::{Client, Event, OutputEventBody, Result, SourceBreakpoint, StoppedEventBody};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use serde_json::from_value; use serde_json::from_value;
use tokio::sync::mpsc::Receiver; use tokio::sync::mpsc::Receiver;
@ -75,7 +75,9 @@ pub async fn main() -> Result<()> {
println!("configurationDone: {:?}", client.configuration_done().await); println!("configurationDone: {:?}", client.configuration_done().await);
println!("stopped: {:?}", stopped_event.recv().await); let stop: StoppedEventBody =
from_value(stopped_event.recv().await.unwrap().body.unwrap()).unwrap();
println!("stopped: {:?}", stop);
println!("threads: {:#?}", client.threads().await); println!("threads: {:#?}", client.threads().await);
let bt = client.stack_trace(1).await.expect("expected stack trace"); let bt = client.stack_trace(1).await.expect("expected stack trace");

@ -267,6 +267,18 @@ pub struct OutputEventBody {
pub data: Option<Value>, pub data: Option<Value>,
} }
#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct StoppedEventBody {
pub reason: String,
pub description: Option<String>,
pub thread_id: Option<usize>,
pub preserve_focus_hint: Option<bool>,
pub text: Option<String>,
pub all_threads_stopped: Option<bool>,
pub hit_breakpoint_ids: Option<Vec<usize>>,
}
#[derive(Debug)] #[derive(Debug)]
pub struct Client { pub struct Client {
id: usize, id: usize,

@ -1,7 +1,7 @@
mod client; mod client;
mod transport; mod transport;
pub use client::{Breakpoint, Client, OutputEventBody, SourceBreakpoint}; pub use client::{Breakpoint, Client, OutputEventBody, SourceBreakpoint, StoppedEventBody};
pub use transport::{Event, Payload, Request, Response, Transport}; pub use transport::{Event, Payload, Request, Response, Transport};
use thiserror::Error; use thiserror::Error;

Loading…
Cancel
Save