on master help sign in
dap: Drop examples
commit155c608237f094a5744e597ade9726dab9202fb7 authorBlaž Hrastnik <blaz@mxxn.io> dateSun 7 Nov 2021, 18:38 (5 years ago) parent9baddc8
2 files changed−252
helix-dap/examples/dap-dlv.rs−125 helix-dap/examples/dap-lldb.rs−127
helix-dap/examples/dap-dlv.rsdeleted−125
@@ -1,125 +0,0 @@
1−use helix_dap::{events, Client, Event, Payload, Result, SourceBreakpoint, ThreadId};
2−use serde::{Deserialize, Serialize};
3−use serde_json::to_value;
4−use tokio::sync::mpsc::UnboundedReceiver;
5−
6−#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)]
7−#[serde(rename_all = "camelCase")]
8−struct LaunchArguments {
9− mode: String,
10− program: String,
11−}
12−
13−async fn dispatch(mut rx: UnboundedReceiver<Payload>) {
14− loop {
15− match rx.recv().await.unwrap() {
16− Payload::Event(Event::Output(events::Output {
17− category, output, ..
18− })) => {
19− println!(
20− "> [{}] {}",
21− category.unwrap_or("unknown".to_owned()),
22− output
23− );
24− }
25− Payload::Event(Event::Stopped(_)) => {
26− println!("stopped");
27− }
28− _ => {}
29− };
30− }
31−}
32−
33−#[tokio::main]
34−pub async fn main() -> Result<()> {
35− let base_config = fern::Dispatch::new().level(log::LevelFilter::Info);
36−
37− let stderr_config = fern::Dispatch::new()
38− .format(|out, message, record| out.finish(format_args!("[{}] {}", record.level(), message)))
39− .chain(std::io::stderr());
40−
41− base_config
42− .chain(stderr_config)
43− .apply()
44− .expect("Failed to set up logging");
45−
46− let (mut client, events) =
47− Client::tcp_process("dlv", vec!["dap"], "-l 127.0.0.1:{}", 0).await?;
48− println!("create: {:?}", client);
49−
50− tokio::spawn(dispatch(events));
51−
52− println!("init: {:?}", client.initialize("go".to_owned()).await);
53− println!("caps: {:?}", client.capabilities());
54−
55− let args = LaunchArguments {
56− mode: "exec".to_owned(),
57− program: "/tmp/godebug/main".to_owned(),
58− };
59−
60− println!("launch: {:?}", client.launch(to_value(args)?).await);
61−
62− println!(
63− "breakpoints: {:#?}",
64− client
65− .set_breakpoints(
66− "/tmp/godebug/main.go".into(),
67− vec![SourceBreakpoint {
68− line: 8,
69− column: Some(2),
70− condition: None,
71− hit_condition: None,
72− log_message: None,
73− }]
74− )
75− .await
76− );
77−
78− let mut _in = String::new();
79− std::io::stdin()
80− .read_line(&mut _in)
81− .expect("Failed to read line");
82−
83− println!("configurationDone: {:?}", client.configuration_done().await);
84−
85− let mut _in = String::new();
86− std::io::stdin()
87− .read_line(&mut _in)
88− .expect("Failed to read line");
89−
90− let threads = client.threads().await?;
91− println!("threads: {:#?}", threads);
92− let bt = client
93− .stack_trace(threads[0].id)
94− .await
95− .expect("expected stack trace");
96− println!("stack trace: {:#?}", bt);
97− let scopes = client
98− .scopes(bt.0[0].id)
99− .await
100− .expect("expected scopes for thread");
101− println!("scopes: {:#?}", scopes);
102− println!(
103− "vars: {:#?}",
104− client.variables(scopes[1].variables_reference).await
105− );
106−
107− let mut _in = String::new();
108− std::io::stdin()
109− .read_line(&mut _in)
110− .expect("Failed to read line");
111−
112− println!(
113− "continued: {:?}",
114− client.continue_thread(ThreadId::default()).await
115− );
116−
117− let mut _in = String::new();
118− std::io::stdin()
119− .read_line(&mut _in)
120− .expect("Failed to read line");
121−
122− println!("disconnect: {:?}", client.disconnect().await);
123−
124− Ok(())
125−}
helix-dap/examples/dap-lldb.rsdeleted−127
@@ -1,127 +0,0 @@
1−use helix_dap::{events, Client, Event, Payload, Result, SourceBreakpoint, ThreadId};
2−use serde::{Deserialize, Serialize};
3−use serde_json::to_value;
4−use tokio::sync::mpsc::UnboundedReceiver;
5−
6−#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)]
7−#[serde(rename_all = "camelCase")]
8−struct LaunchArguments {
9− program: String,
10− console: String,
11−}
12−
13−async fn dispatch(mut rx: UnboundedReceiver<Payload>) {
14− loop {
15− match rx.recv().await.unwrap() {
16− Payload::Event(Event::Output(events::Output {
17− category, output, ..
18− })) => {
19− println!(
20− "> [{}] {}",
21− category.unwrap_or("unknown".to_owned()),
22− output
23− );
24− }
25− Payload::Event(Event::Stopped(_)) => {
26− println!("stopped");
27− }
28− _ => {}
29− };
30− }
31−}
32−
33−#[tokio::main]
34−pub async fn main() -> Result<()> {
35− let base_config = fern::Dispatch::new().level(log::LevelFilter::Info);
36−
37− let stderr_config = fern::Dispatch::new()
38− .format(|out, message, record| out.finish(format_args!("[{}] {}", record.level(), message)))
39− .chain(std::io::stderr());
40−
41− base_config
42− .chain(stderr_config)
43− .apply()
44− .expect("Failed to set up logging");
45−
46− let (mut client, events) = Client::tcp_process("lldb-vscode", vec![], "-p {}", 0).await?;
47− println!("create: {:?}", client);
48−
49− tokio::spawn(dispatch(events));
50−
51− println!(
52− "init: {:?}",
53− client.initialize("lldb-vscode".to_owned()).await
54− );
55− println!("caps: {:?}", client.capabilities());
56−
57− let args = LaunchArguments {
58− program: "/tmp/cdebug/main".to_owned(),
59− console: "internalConsole".to_owned(),
60− };
61−
62− println!("launch: {:?}", client.launch(to_value(args)?).await);
63−
64− println!(
65− "breakpoints: {:#?}",
66− client
67− .set_breakpoints(
68− "/tmp/cdebug/main.c".into(),
69− vec![SourceBreakpoint {
70− line: 6,
71− column: Some(2),
72− condition: None,
73− hit_condition: None,
74− log_message: None,
75− }]
76− )
77− .await
78− );
79−
80− let mut _in = String::new();
81− std::io::stdin()
82− .read_line(&mut _in)
83− .expect("Failed to read line");
84−
85− println!("configurationDone: {:?}", client.configuration_done().await);
86−
87− let mut _in = String::new();
88− std::io::stdin()
89− .read_line(&mut _in)
90− .expect("Failed to read line");
91−
92− let threads = client.threads().await?;
93− println!("threads: {:#?}", threads);
94− let bt = client
95− .stack_trace(threads[0].id)
96− .await
97− .expect("expected stack trace");
98− println!("stack trace: {:#?}", bt);
99− let scopes = client
100− .scopes(bt.0[0].id)
101− .await
102− .expect("expected scopes for thread");
103− println!("scopes: {:#?}", scopes);
104− println!(
105− "vars: {:#?}",
106− client.variables(scopes[0].variables_reference).await
107− );
108−
109− let mut _in = String::new();
110− std::io::stdin()
111− .read_line(&mut _in)
112− .expect("Failed to read line");
113−
114− println!(
115− "continued: {:?}",
116− client.continue_thread(ThreadId::default()).await
117− );
118−
119− let mut _in = String::new();
120− std::io::stdin()
121− .read_line(&mut _in)
122− .expect("Failed to read line");
123−
124− println!("disconnect: {:?}", client.disconnect().await);
125−
126− Ok(())
127−}