aboutsummaryrefslogtreecommitdiff
path: root/helix-dap/src
diff options
context:
space:
mode:
Diffstat (limited to 'helix-dap/src')
-rw-r--r--helix-dap/src/client.rs28
-rw-r--r--helix-dap/src/lib.rs2
-rw-r--r--helix-dap/src/types.rs13
3 files changed, 36 insertions, 7 deletions
diff --git a/helix-dap/src/client.rs b/helix-dap/src/client.rs
index 10d93180..f6d8a069 100644
--- a/helix-dap/src/client.rs
+++ b/helix-dap/src/client.rs
@@ -1,4 +1,5 @@
use crate::{
+ requests::DisconnectArguments,
transport::{Payload, Request, Response, Transport},
types::*,
Error, Result, ThreadId,
@@ -31,6 +32,7 @@ pub struct Client {
_process: Option<Child>,
server_tx: UnboundedSender<Payload>,
request_counter: AtomicU64,
+ connection_type: Option<ConnectionType>,
pub caps: Option<DebuggerCapabilities>,
// thread_id -> frames
pub stack_frames: HashMap<ThreadId, Vec<StackFrame>>,
@@ -41,6 +43,12 @@ pub struct Client {
pub quirks: DebuggerQuirks,
}
+#[derive(Clone, Copy, Debug)]
+pub enum ConnectionType {
+ Launch,
+ Attach,
+}
+
impl Client {
// Spawn a process and communicate with it by either TCP or stdio
pub async fn process(
@@ -78,7 +86,7 @@ impl Client {
server_tx,
request_counter: AtomicU64::new(0),
caps: None,
- //
+ connection_type: None,
stack_frames: HashMap::new(),
thread_states: HashMap::new(),
thread_id: None,
@@ -207,6 +215,10 @@ impl Client {
self.id
}
+ pub fn connection_type(&self) -> Option<ConnectionType> {
+ self.connection_type
+ }
+
fn next_request_id(&self) -> u64 {
self.request_counter.fetch_add(1, Ordering::Relaxed)
}
@@ -334,15 +346,21 @@ impl Client {
Ok(())
}
- pub fn disconnect(&self) -> impl Future<Output = Result<Value>> {
- self.call::<requests::Disconnect>(())
+ pub fn disconnect(
+ &mut self,
+ args: Option<DisconnectArguments>,
+ ) -> impl Future<Output = Result<Value>> {
+ self.connection_type = None;
+ self.call::<requests::Disconnect>(args)
}
- pub fn launch(&self, args: serde_json::Value) -> impl Future<Output = Result<Value>> {
+ pub fn launch(&mut self, args: serde_json::Value) -> impl Future<Output = Result<Value>> {
+ self.connection_type = Some(ConnectionType::Launch);
self.call::<requests::Launch>(args)
}
- pub fn attach(&self, args: serde_json::Value) -> impl Future<Output = Result<Value>> {
+ pub fn attach(&mut self, args: serde_json::Value) -> impl Future<Output = Result<Value>> {
+ self.connection_type = Some(ConnectionType::Attach);
self.call::<requests::Attach>(args)
}
diff --git a/helix-dap/src/lib.rs b/helix-dap/src/lib.rs
index 24d7472b..21162cb8 100644
--- a/helix-dap/src/lib.rs
+++ b/helix-dap/src/lib.rs
@@ -2,7 +2,7 @@ mod client;
mod transport;
mod types;
-pub use client::Client;
+pub use client::{Client, ConnectionType};
pub use events::Event;
pub use transport::{Payload, Response, Transport};
pub use types::*;
diff --git a/helix-dap/src/types.rs b/helix-dap/src/types.rs
index 0a9ebe5e..c598790b 100644
--- a/helix-dap/src/types.rs
+++ b/helix-dap/src/types.rs
@@ -391,11 +391,22 @@ pub mod requests {
const COMMAND: &'static str = "attach";
}
+ #[derive(Debug, Default, PartialEq, Eq, Clone, Deserialize, Serialize)]
+ #[serde(rename_all = "camelCase")]
+ pub struct DisconnectArguments {
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub restart: Option<bool>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub terminate_debuggee: Option<bool>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub suspend_debuggee: Option<bool>,
+ }
+
#[derive(Debug)]
pub enum Disconnect {}
impl Request for Disconnect {
- type Arguments = ();
+ type Arguments = Option<DisconnectArguments>;
type Result = ();
const COMMAND: &'static str = "disconnect";
}