aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Sharshakov2021-08-12 16:35:55 +0000
committerBlaž Hrastnik2021-08-20 04:43:54 +0000
commit7d2d4ed4a86f28bfce8d2fda8a774701d80f5175 (patch)
tree77f047f0863d532c2ba941e6ac991ffd1f443bc2
parent5f3e8063415291e91d856fe3ed1eea16b058d0e1 (diff)
dap: implement threads request
-rw-r--r--helix-dap/examples/dap-basic.rs1
-rw-r--r--helix-dap/src/client.rs21
2 files changed, 22 insertions, 0 deletions
diff --git a/helix-dap/examples/dap-basic.rs b/helix-dap/examples/dap-basic.rs
index 434f2eeb..cc05cd8e 100644
--- a/helix-dap/examples/dap-basic.rs
+++ b/helix-dap/examples/dap-basic.rs
@@ -42,6 +42,7 @@ pub async fn main() -> Result<()> {
println!("configurationDone: {:?}", client.configuration_done().await);
println!("stopped: {:?}", client.wait_for_stopped().await);
+ println!("threads: {:#?}", client.threads().await);
println!("stack trace: {:#?}", client.stack_trace(1).await);
let mut _in = String::new();
diff --git a/helix-dap/src/client.rs b/helix-dap/src/client.rs
index 37f264ec..d76f9af3 100644
--- a/helix-dap/src/client.rs
+++ b/helix-dap/src/client.rs
@@ -148,6 +148,19 @@ struct StackTraceResponseBody {
stack_frames: Vec<StackFrame>,
}
+#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)]
+#[serde(rename_all = "camelCase")]
+pub struct Thread {
+ id: usize,
+ name: String,
+}
+
+#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)]
+#[serde(rename_all = "camelCase")]
+struct ThreadsResponseBody {
+ threads: Vec<Thread>,
+}
+
#[derive(Debug)]
pub struct Client {
id: usize,
@@ -349,4 +362,12 @@ impl Client {
Ok((body.stack_frames, body.total_frames))
}
+
+ pub async fn threads(&mut self) -> Result<Vec<Thread>> {
+ let response = self.request("threads".to_owned(), None).await?;
+
+ let body: ThreadsResponseBody = from_value(response.body.unwrap()).unwrap();
+
+ Ok(body.threads)
+ }
}