1mod codelldb;
2mod gdb;
3mod go;
4mod javascript;
5mod php;
6mod python;
7
8use std::sync::Arc;
9
10use anyhow::Result;
11use async_trait::async_trait;
12use codelldb::CodeLldbDebugAdapter;
13use dap::{
14 DapRegistry,
15 adapters::{
16 self, AdapterVersion, DapDelegate, DebugAdapter, DebugAdapterBinary, DebugAdapterName,
17 GithubRepo,
18 },
19 configure_tcp_connection,
20};
21use gdb::GdbDebugAdapter;
22use go::GoDebugAdapter;
23use gpui::{App, BorrowAppContext};
24pub use javascript::JsDebugAdapter;
25use php::PhpDebugAdapter;
26use python::PythonDebugAdapter;
27use serde_json::json;
28use task::{DebugScenario, ZedDebugConfig};
29
30pub fn init(cx: &mut App) {
31 cx.update_default_global(|registry: &mut DapRegistry, _cx| {
32 registry.add_adapter(Arc::from(CodeLldbDebugAdapter::default()));
33 registry.add_adapter(Arc::from(PythonDebugAdapter::default()));
34 registry.add_adapter(Arc::from(PhpDebugAdapter::default()));
35 registry.add_adapter(Arc::from(JsDebugAdapter::default()));
36 registry.add_adapter(Arc::from(GoDebugAdapter::default()));
37 registry.add_adapter(Arc::from(GdbDebugAdapter));
38
39 #[cfg(any(test, feature = "test-support"))]
40 {
41 registry.add_adapter(Arc::from(dap::FakeAdapter {}));
42 }
43 })
44}
45
46#[cfg(feature = "update-schemas")]
47struct UpdateSchemasDapDelegate {
48 client: std::sync::Arc<reqwest_client::ReqwestClient>,
49 fs: std::sync::Arc<fs::RealFs>,
50}
51
52#[cfg(feature = "update-schemas")]
53impl UpdateSchemasDapDelegate {
54 fn new(executor: gpui::BackgroundExecutor) -> Self {
55 // FIXME
56 let client = Arc::new(reqwest_client::ReqwestClient::user_agent("Cole").unwrap());
57 let fs = Arc::new(fs::RealFs::new(None, executor.clone()));
58 Self { client, fs }
59 }
60}
61
62#[cfg(feature = "update-schemas")]
63#[async_trait]
64impl dap::adapters::DapDelegate for UpdateSchemasDapDelegate {
65 fn worktree_id(&self) -> settings::WorktreeId {
66 unreachable!()
67 }
68 fn worktree_root_path(&self) -> &std::path::Path {
69 unreachable!()
70 }
71 fn http_client(&self) -> Arc<dyn dap::adapters::HttpClient> {
72 self.client.clone()
73 }
74 fn node_runtime(&self) -> node_runtime::NodeRuntime {
75 unreachable!()
76 }
77 fn toolchain_store(&self) -> Arc<dyn language::LanguageToolchainStore> {
78 unreachable!()
79 }
80 fn fs(&self) -> Arc<dyn fs::Fs> {
81 self.fs.clone()
82 }
83 fn output_to_console(&self, _msg: String) {}
84 async fn which(&self, _command: &std::ffi::OsStr) -> Option<std::path::PathBuf> {
85 unreachable!()
86 }
87 async fn read_text_file(&self, _path: std::path::PathBuf) -> Result<String> {
88 unreachable!()
89 }
90 async fn shell_env(&self) -> collections::HashMap<String, String> {
91 unreachable!()
92 }
93}