aboutsummaryrefslogtreecommitdiff
path: root/helix-dap
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-11-07 09:38:27 +0000
committerBlaž Hrastnik2021-11-07 09:38:27 +0000
commit155c608237f094a5744e597ade9726dab9202fb7 (patch)
tree70ae5266fbb3305bae5b55fc15c484a7e9e37a47 /helix-dap
parent9baddc825d57e09e635b653b2c171e104f85c552 (diff)
dap: Drop examples
Diffstat (limited to 'helix-dap')
-rw-r--r--helix-dap/examples/dap-dlv.rs125
-rw-r--r--helix-dap/examples/dap-lldb.rs127
2 files changed, 0 insertions, 252 deletions
diff --git a/helix-dap/examples/dap-dlv.rs b/helix-dap/examples/dap-dlv.rs
deleted file mode 100644
index 24b26a74..00000000
--- a/helix-dap/examples/dap-dlv.rs
+++ /dev/null
@@ -1,125 +0,0 @@
-use helix_dap::{events, Client, Event, Payload, Result, SourceBreakpoint, ThreadId};
-use serde::{Deserialize, Serialize};
-use serde_json::to_value;
-use tokio::sync::mpsc::UnboundedReceiver;
-
-#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)]
-#[serde(rename_all = "camelCase")]
-struct LaunchArguments {
- mode: String,
- program: String,
-}
-
-async fn dispatch(mut rx: UnboundedReceiver<Payload>) {
- loop {
- match rx.recv().await.unwrap() {
- Payload::Event(Event::Output(events::Output {
- category, output, ..
- })) => {
- println!(
- "> [{}] {}",
- category.unwrap_or("unknown".to_owned()),
- output
- );
- }
- Payload::Event(Event::Stopped(_)) => {
- println!("stopped");
- }
- _ => {}
- };
- }
-}
-
-#[tokio::main]
-pub async fn main() -> Result<()> {
- let base_config = fern::Dispatch::new().level(log::LevelFilter::Info);
-
- let stderr_config = fern::Dispatch::new()
- .format(|out, message, record| out.finish(format_args!("[{}] {}", record.level(), message)))
- .chain(std::io::stderr());
-
- base_config
- .chain(stderr_config)
- .apply()
- .expect("Failed to set up logging");
-
- let (mut client, events) =
- Client::tcp_process("dlv", vec!["dap"], "-l 127.0.0.1:{}", 0).await?;
- println!("create: {:?}", client);
-
- tokio::spawn(dispatch(events));
-
- println!("init: {:?}", client.initialize("go".to_owned()).await);
- println!("caps: {:?}", client.capabilities());
-
- let args = LaunchArguments {
- mode: "exec".to_owned(),
- program: "/tmp/godebug/main".to_owned(),
- };
-
- println!("launch: {:?}", client.launch(to_value(args)?).await);
-
- println!(
- "breakpoints: {:#?}",
- client
- .set_breakpoints(
- "/tmp/godebug/main.go".into(),
- vec![SourceBreakpoint {
- line: 8,
- column: Some(2),
- condition: None,
- hit_condition: None,
- log_message: None,
- }]
- )
- .await
- );
-
- let mut _in = String::new();
- std::io::stdin()
- .read_line(&mut _in)
- .expect("Failed to read line");
-
- println!("configurationDone: {:?}", client.configuration_done().await);
-
- let mut _in = String::new();
- std::io::stdin()
- .read_line(&mut _in)
- .expect("Failed to read line");
-
- let threads = client.threads().await?;
- println!("threads: {:#?}", threads);
- let bt = client
- .stack_trace(threads[0].id)
- .await
- .expect("expected stack trace");
- println!("stack trace: {:#?}", bt);
- let scopes = client
- .scopes(bt.0[0].id)
- .await
- .expect("expected scopes for thread");
- println!("scopes: {:#?}", scopes);
- println!(
- "vars: {:#?}",
- client.variables(scopes[1].variables_reference).await
- );
-
- let mut _in = String::new();
- std::io::stdin()
- .read_line(&mut _in)
- .expect("Failed to read line");
-
- println!(
- "continued: {:?}",
- client.continue_thread(ThreadId::default()).await
- );
-
- let mut _in = String::new();
- std::io::stdin()
- .read_line(&mut _in)
- .expect("Failed to read line");
-
- println!("disconnect: {:?}", client.disconnect().await);
-
- Ok(())
-}
diff --git a/helix-dap/examples/dap-lldb.rs b/helix-dap/examples/dap-lldb.rs
deleted file mode 100644
index 935de5fe..00000000
--- a/helix-dap/examples/dap-lldb.rs
+++ /dev/null
@@ -1,127 +0,0 @@
-use helix_dap::{events, Client, Event, Payload, Result, SourceBreakpoint, ThreadId};
-use serde::{Deserialize, Serialize};
-use serde_json::to_value;
-use tokio::sync::mpsc::UnboundedReceiver;
-
-#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)]
-#[serde(rename_all = "camelCase")]
-struct LaunchArguments {
- program: String,
- console: String,
-}
-
-async fn dispatch(mut rx: UnboundedReceiver<Payload>) {
- loop {
- match rx.recv().await.unwrap() {
- Payload::Event(Event::Output(events::Output {
- category, output, ..
- })) => {
- println!(
- "> [{}] {}",
- category.unwrap_or("unknown".to_owned()),
- output
- );
- }
- Payload::Event(Event::Stopped(_)) => {
- println!("stopped");
- }
- _ => {}
- };
- }
-}
-
-#[tokio::main]
-pub async fn main() -> Result<()> {
- let base_config = fern::Dispatch::new().level(log::LevelFilter::Info);
-
- let stderr_config = fern::Dispatch::new()
- .format(|out, message, record| out.finish(format_args!("[{}] {}", record.level(), message)))
- .chain(std::io::stderr());
-
- base_config
- .chain(stderr_config)
- .apply()
- .expect("Failed to set up logging");
-
- let (mut client, events) = Client::tcp_process("lldb-vscode", vec![], "-p {}", 0).await?;
- println!("create: {:?}", client);
-
- tokio::spawn(dispatch(events));
-
- println!(
- "init: {:?}",
- client.initialize("lldb-vscode".to_owned()).await
- );
- println!("caps: {:?}", client.capabilities());
-
- let args = LaunchArguments {
- program: "/tmp/cdebug/main".to_owned(),
- console: "internalConsole".to_owned(),
- };
-
- println!("launch: {:?}", client.launch(to_value(args)?).await);
-
- println!(
- "breakpoints: {:#?}",
- client
- .set_breakpoints(
- "/tmp/cdebug/main.c".into(),
- vec![SourceBreakpoint {
- line: 6,
- column: Some(2),
- condition: None,
- hit_condition: None,
- log_message: None,
- }]
- )
- .await
- );
-
- let mut _in = String::new();
- std::io::stdin()
- .read_line(&mut _in)
- .expect("Failed to read line");
-
- println!("configurationDone: {:?}", client.configuration_done().await);
-
- let mut _in = String::new();
- std::io::stdin()
- .read_line(&mut _in)
- .expect("Failed to read line");
-
- let threads = client.threads().await?;
- println!("threads: {:#?}", threads);
- let bt = client
- .stack_trace(threads[0].id)
- .await
- .expect("expected stack trace");
- println!("stack trace: {:#?}", bt);
- let scopes = client
- .scopes(bt.0[0].id)
- .await
- .expect("expected scopes for thread");
- println!("scopes: {:#?}", scopes);
- println!(
- "vars: {:#?}",
- client.variables(scopes[0].variables_reference).await
- );
-
- let mut _in = String::new();
- std::io::stdin()
- .read_line(&mut _in)
- .expect("Failed to read line");
-
- println!(
- "continued: {:?}",
- client.continue_thread(ThreadId::default()).await
- );
-
- let mut _in = String::new();
- std::io::stdin()
- .read_line(&mut _in)
- .expect("Failed to read line");
-
- println!("disconnect: {:?}", client.disconnect().await);
-
- Ok(())
-}