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

@ -187,6 +187,16 @@ pub trait Extension: Send + Sync {
) -> Result<(), String> {
Err("`index_docs` not implemented".to_string())
}
/// Returns the debug adapter binary for the specified adapter name and configuration.
fn get_dap_binary(
&mut self,
_adapter_name: String,
_config: DebugTaskDefinition,
_user_provided_path: Option<String>,
) -> Result<DebugAdapterBinary, String> {
Err("`get_dap_binary` not implemented".to_string())
}
}
/// Registers the provided type as a Zed extension.
@ -371,6 +381,14 @@ impl wit::Guest for Component {
) -> Result<(), String> {
extension().index_docs(provider, package, database)
}
fn get_dap_binary(
adapter_name: String,
config: DebugTaskDefinition,
user_installed_path: Option<String>,
) -> Result<DebugAdapterBinary, String> {
extension().get_dap_binary(adapter_name, config, user_installed_path)
}
}
/// The ID of a language server.

View file

@ -0,0 +1,56 @@
interface dap {
use common.{env-vars};
record launch-request {
program: string,
cwd: option<string>,
args: list<string>,
envs: env-vars,
}
record attach-request {
process-id: option<u32>,
}
variant debug-request {
launch(launch-request),
attach(attach-request)
}
record tcp-arguments {
port: u16,
host: u32,
timeout: option<u64>,
}
record tcp-arguments-template {
port: option<u16>,
host: option<u32>,
timeout: option<u64>,
}
record debug-task-definition {
label: string,
adapter: string,
request: debug-request,
initialize-args: option<string>,
stop-on-entry: option<bool>,
tcp-connection: option<tcp-arguments-template>,
}
enum start-debugging-request-arguments-request {
launch,
attach,
}
record start-debugging-request-arguments {
configuration: string,
request: start-debugging-request-arguments-request,
}
record debug-adapter-binary {
command: string,
arguments: list<string>,
envs: env-vars,
cwd: option<string>,
connection: option<tcp-arguments>,
request-args: start-debugging-request-arguments
}
}

View file

@ -2,6 +2,7 @@ package zed:extension;
world extension {
import context-server;
import dap;
import github;
import http-client;
import platform;
@ -10,6 +11,7 @@ world extension {
use common.{env-vars, range};
use context-server.{context-server-configuration};
use dap.{debug-adapter-binary, debug-task-definition};
use lsp.{completion, symbol};
use process.{command};
use slash-command.{slash-command, slash-command-argument-completion, slash-command-output};
@ -153,4 +155,7 @@ world extension {
/// Indexes the docs for the specified package.
export index-docs: func(provider-name: string, package-name: string, database: borrow<key-value-store>) -> result<_, string>;
/// Returns a configured debug adapter binary for a given debug task.
export get-dap-binary: func(adapter-name: string, config: debug-task-definition, user-installed-path: option<string>) -> result<debug-adapter-binary, string>;
}