From dfc70a12f337df57e69e3613896663c2f446df8e Mon Sep 17 00:00:00 2001 From: Dmitry Sharshakov Date: Sun, 22 Aug 2021 11:02:54 +0300 Subject: [PATCH] dap: support stepIn, stepOut, next and pause commands --- helix-dap/src/client.rs | 36 +++++++++++++++++++++++ helix-dap/src/types.rs | 64 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 100 insertions(+) diff --git a/helix-dap/src/client.rs b/helix-dap/src/client.rs index cfb278a9b..e2531e11d 100644 --- a/helix-dap/src/client.rs +++ b/helix-dap/src/client.rs @@ -316,4 +316,40 @@ impl Client { let response = self.request::(args).await?; Ok(response.variables) } + + pub async fn step_in(&mut self, thread_id: usize) -> Result<()> { + let args = requests::StepInArguments { + thread_id, + target_id: None, + granularity: None, + }; + + self.request::(args).await + } + + pub async fn step_out(&mut self, thread_id: usize) -> Result<()> { + let args = requests::StepOutArguments { + thread_id, + granularity: None, + }; + + self.request::(args).await + } + + pub async fn next(&mut self, thread_id: usize) -> Result<()> { + let args = requests::NextArguments { + thread_id, + granularity: None, + }; + + self.request::(args).await + } + + pub async fn pause(&mut self, thread_id: usize) -> Result<()> { + let args = requests::PauseArguments { + thread_id, + }; + + self.request::(args).await + } } diff --git a/helix-dap/src/types.rs b/helix-dap/src/types.rs index fcbbf184d..4ee796b35 100644 --- a/helix-dap/src/types.rs +++ b/helix-dap/src/types.rs @@ -420,6 +420,70 @@ pub mod requests { type Result = VariablesResponse; const COMMAND: &'static str = "variables"; } + + #[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] + #[serde(rename_all = "camelCase")] + pub struct StepInArguments { + pub thread_id: usize, + pub target_id: Option, + pub granularity: Option, + } + + #[derive(Debug)] + pub enum StepIn {} + + impl Request for StepIn { + type Arguments = StepInArguments; + type Result = (); + const COMMAND: &'static str = "stepIn"; + } + + #[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] + #[serde(rename_all = "camelCase")] + pub struct StepOutArguments { + pub thread_id: usize, + pub granularity: Option, + } + + #[derive(Debug)] + pub enum StepOut {} + + impl Request for StepOut { + type Arguments = StepOutArguments; + type Result = (); + const COMMAND: &'static str = "stepOut"; + } + + #[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] + #[serde(rename_all = "camelCase")] + pub struct NextArguments { + pub thread_id: usize, + pub granularity: Option, + } + + #[derive(Debug)] + pub enum Next {} + + impl Request for Next { + type Arguments = NextArguments; + type Result = (); + const COMMAND: &'static str = "next"; + } + + #[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] + #[serde(rename_all = "camelCase")] + pub struct PauseArguments { + pub thread_id: usize, + } + + #[derive(Debug)] + pub enum Pause {} + + impl Request for Pause { + type Arguments = PauseArguments; + type Result = (); + const COMMAND: &'static str = "pause"; + } } // Events