From 3197c2536ecb0f4f7aa4dfb75ece549b72249541 Mon Sep 17 00:00:00 2001 From: Dmitry Sharshakov Date: Sun, 22 Aug 2021 14:44:16 +0300 Subject: Add eval command --- helix-dap/src/client.rs | 15 +++++++++++++++ helix-dap/src/types.rs | 31 +++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) (limited to 'helix-dap/src') diff --git a/helix-dap/src/client.rs b/helix-dap/src/client.rs index ebaae83c..98b88e23 100644 --- a/helix-dap/src/client.rs +++ b/helix-dap/src/client.rs @@ -352,4 +352,19 @@ impl Client { self.request::(args).await } + + pub async fn eval( + &mut self, + expression: String, + frame_id: Option, + ) -> Result { + let args = requests::EvaluateArguments { + expression, + frame_id, + context: None, + format: None, + }; + + self.request::(args).await + } } diff --git a/helix-dap/src/types.rs b/helix-dap/src/types.rs index 4ee796b3..bb73e5e9 100644 --- a/helix-dap/src/types.rs +++ b/helix-dap/src/types.rs @@ -484,6 +484,37 @@ pub mod requests { type Result = (); const COMMAND: &'static str = "pause"; } + + #[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] + #[serde(rename_all = "camelCase")] + pub struct EvaluateArguments { + pub expression: String, + pub frame_id: Option, + pub context: Option, + pub format: Option, + } + + #[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] + #[serde(rename_all = "camelCase")] + pub struct EvaluateResponse { + pub result: String, + #[serde(rename = "type")] + pub data_type: Option, + pub presentation_hint: Option, + pub variables_reference: usize, + pub named_variables: Option, + pub indexed_variables: Option, + pub memory_reference: Option, + } + + #[derive(Debug)] + pub enum Evaluate {} + + impl Request for Evaluate { + type Arguments = EvaluateArguments; + type Result = EvaluateResponse; + const COMMAND: &'static str = "evaluate"; + } } // Events -- cgit v1.2.3-70-g09d2