debugger: Add extensions support (#30625)

Closes #ISSUE

Release Notes:

- N/A

---------

Co-authored-by: Anthony <anthony@zed.dev>
This commit is contained in:
Piotr Osiewicz 2025-05-14 00:42:51 +02:00 committed by GitHub
parent 6fc9036063
commit 9826b7b5c1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
21 changed files with 402 additions and 13 deletions

View file

@ -17,6 +17,7 @@ async-compression.workspace = true
async-tar.workspace = true
async-trait.workspace = true
collections.workspace = true
dap.workspace = true
fs.workspace = true
futures.workspace = true
gpui.workspace = true
@ -29,6 +30,7 @@ parking_lot.workspace = true
semantic_version.workspace = true
serde.workspace = true
serde_json.workspace = true
task.workspace = true
toml.workspace = true
util.workspace = true
wasm-encoder.workspace = true

View file

@ -135,6 +135,13 @@ pub trait Extension: Send + Sync + 'static {
package_name: Arc<str>,
kv_store: Arc<dyn KeyValueStoreDelegate>,
) -> Result<()>;
async fn get_dap_binary(
&self,
dap_name: Arc<str>,
config: DebugTaskDefinition,
user_installed_path: Option<PathBuf>,
) -> Result<DebugAdapterBinary>;
}
pub fn parse_wasm_extension_version(

View file

@ -29,6 +29,7 @@ pub struct ExtensionHostProxy {
slash_command_proxy: RwLock<Option<Arc<dyn ExtensionSlashCommandProxy>>>,
context_server_proxy: RwLock<Option<Arc<dyn ExtensionContextServerProxy>>>,
indexed_docs_provider_proxy: RwLock<Option<Arc<dyn ExtensionIndexedDocsProviderProxy>>>,
debug_adapter_provider_proxy: RwLock<Option<Arc<dyn ExtensionDebugAdapterProviderProxy>>>,
}
impl ExtensionHostProxy {
@ -54,6 +55,7 @@ impl ExtensionHostProxy {
slash_command_proxy: RwLock::default(),
context_server_proxy: RwLock::default(),
indexed_docs_provider_proxy: RwLock::default(),
debug_adapter_provider_proxy: RwLock::default(),
}
}
@ -93,6 +95,11 @@ impl ExtensionHostProxy {
.write()
.replace(Arc::new(proxy));
}
pub fn register_debug_adapter_proxy(&self, proxy: impl ExtensionDebugAdapterProviderProxy) {
self.debug_adapter_provider_proxy
.write()
.replace(Arc::new(proxy));
}
}
pub trait ExtensionThemeProxy: Send + Sync + 'static {
@ -402,3 +409,17 @@ impl ExtensionIndexedDocsProviderProxy for ExtensionHostProxy {
proxy.register_indexed_docs_provider(extension, provider_id)
}
}
pub trait ExtensionDebugAdapterProviderProxy: Send + Sync + 'static {
fn register_debug_adapter(&self, extension: Arc<dyn Extension>, debug_adapter_name: Arc<str>);
}
impl ExtensionDebugAdapterProviderProxy for ExtensionHostProxy {
fn register_debug_adapter(&self, extension: Arc<dyn Extension>, debug_adapter_name: Arc<str>) {
let Some(proxy) = self.debug_adapter_provider_proxy.read().clone() else {
return;
};
proxy.register_debug_adapter(extension, debug_adapter_name)
}
}

View file

@ -1,10 +1,12 @@
mod context_server;
mod dap;
mod lsp;
mod slash_command;
use std::ops::Range;
pub use context_server::*;
pub use dap::*;
pub use lsp::*;
pub use slash_command::*;

View file

@ -0,0 +1,5 @@
pub use dap::{
StartDebuggingRequestArguments, StartDebuggingRequestArgumentsRequest,
adapters::{DebugAdapterBinary, DebugTaskDefinition, TcpArguments},
};
pub use task::{AttachRequest, DebugRequest, LaunchRequest, TcpArgumentsTemplate};