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")]
53#[async_trait]
54impl dap::adapters::DapDelegate for UpdateSchemasDapDelegate {
55 fn worktree_id(&self) -> settings::WorktreeId {
56 unreachable!()
57 }
58 fn worktree_root_path(&self) -> &std::path::Path {
59 unreachable!()
60 }
61 fn http_client(&self) -> Arc<dyn dap::adapters::HttpClient> {
62 self.client.clone()
63 }
64 fn node_runtime(&self) -> node_runtime::NodeRuntime {
65 unreachable!()
66 }
67 fn toolchain_store(&self) -> Arc<dyn language::LanguageToolchainStore> {
68 unreachable!()
69 }
70 fn fs(&self) -> Arc<dyn fs::Fs> {
71 self.fs.clone()
72 }
73 fn output_to_console(&self, _msg: String) {}
74 async fn which(&self, _command: &std::ffi::OsStr) -> Option<std::path::PathBuf> {
75 unreachable!()
76 }
77 async fn read_text_file(&self, _path: std::path::PathBuf) -> Result<String> {
78 unreachable!()
79 }
80 async fn shell_env(&self) -> collections::HashMap<String, String> {
81 unreachable!()
82 }
83}