on master help sign in
dap: move launch request argumets outside of client
6bb653fDmitry Sharshakov
helix-dap/examples/dap-basic.rs+15−1
@@ -1,4 +1,12 @@
1use helix_dap::{Client, Result, SourceBreakpoint};
1use helix_dap::{Client, Result, SourceBreakpoint};
2+use serde::{Deserialize, Serialize};
3+
4+#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)]
5+#[serde(rename_all = "camelCase")]
6+struct LaunchArguments {
7+ mode: String,
8+ program: String,
9+}
2
10
3#[tokio::main]
11#[tokio::main]
4pub async fn main() -> Result<()> {
12pub async fn main() -> Result<()> {
@@ -19,9 +27,15 @@ pub async fn main() -> Result<()> {
19
27
20 println!("init: {:?}", client.initialize("go".to_owned()).await);
28 println!("init: {:?}", client.initialize("go".to_owned()).await);
21 println!("caps: {:#?}", client.capabilities());
29 println!("caps: {:#?}", client.capabilities());
30+
31+ let args = LaunchArguments {
32+ mode: "exec".to_owned(),
33+ program: "/tmp/godebug/main".to_owned(),
34+ };
35+
22 println!(
36 println!(
23 "launch: {:?}",
37 "launch: {:?}",
24− client.launch("/tmp/godebug/main".to_owned()).await
38+ client.launch(serde_json::to_value(args)?).await
25 );
39 );
26
40
27 println!(
41 println!(
helix-dap/src/client.rs+2−16
@@ -45,14 +45,6 @@ struct InitializeArguments {
45 supports_invalidated_event: bool,
45 supports_invalidated_event: bool,
46}
46}
47
47
48−// TODO: split out, as it's a debugger-specific payload not covered by standard
49−#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)]
50−#[serde(rename_all = "camelCase")]
51−struct LaunchArguments {
52− mode: String,
53− program: String,
54−}
55−
56#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)]
48#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)]
57#[serde(rename_all = "camelCase")]
49#[serde(rename_all = "camelCase")]
58pub struct Checksum {
50pub struct Checksum {
@@ -380,14 +372,8 @@ impl Client {
380 Ok(())
372 Ok(())
381 }
373 }
382
374
383− pub async fn launch(&mut self, executable: String) -> Result<()> {
375+ pub async fn launch(&mut self, args: Value) -> Result<()> {
384− let args = LaunchArguments {
385− mode: "exec".to_owned(),
386− program: executable,
387− };
388−
389− self.request("launch".to_owned(), to_value(args).ok())
376+ self.request("launch".to_owned(), Some(args)).await?;
390− .await?;
391
377
392 match self
378 match self
393 .server_rx
379 .server_rx