extension: Update DAP extension API (#32448)
- DAP schemas will be stored in `debug_adapters_schemas` subdirectory in extension work dir. - Added Debug Config integration and such. Release Notes: - N/A
This commit is contained in:
parent
41e9f3148c
commit
8df6ce2aac
28 changed files with 620 additions and 47 deletions
|
@ -14,6 +14,7 @@ use fs::normalize_path;
|
|||
use gpui::{App, Task};
|
||||
use language::LanguageName;
|
||||
use semantic_version::SemanticVersion;
|
||||
use task::{SpawnInTerminal, ZedDebugConfig};
|
||||
|
||||
pub use crate::extension_events::*;
|
||||
pub use crate::extension_host_proxy::*;
|
||||
|
@ -144,7 +145,30 @@ pub trait Extension: Send + Sync + 'static {
|
|||
worktree: Arc<dyn WorktreeDelegate>,
|
||||
) -> Result<DebugAdapterBinary>;
|
||||
|
||||
async fn get_dap_schema(&self) -> Result<serde_json::Value>;
|
||||
async fn dap_request_kind(
|
||||
&self,
|
||||
dap_name: Arc<str>,
|
||||
config: serde_json::Value,
|
||||
) -> Result<StartDebuggingRequestArgumentsRequest>;
|
||||
|
||||
async fn dap_config_to_scenario(
|
||||
&self,
|
||||
config: ZedDebugConfig,
|
||||
worktree: Arc<dyn WorktreeDelegate>,
|
||||
) -> Result<DebugScenario>;
|
||||
|
||||
async fn dap_locator_create_scenario(
|
||||
&self,
|
||||
locator_name: String,
|
||||
build_config_template: BuildTaskTemplate,
|
||||
resolved_label: String,
|
||||
debug_adapter_name: String,
|
||||
) -> Result<Option<DebugScenario>>;
|
||||
async fn run_dap_locator(
|
||||
&self,
|
||||
locator_name: String,
|
||||
config: SpawnInTerminal,
|
||||
) -> Result<DebugRequest>;
|
||||
}
|
||||
|
||||
pub fn parse_wasm_extension_version(
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use crate::{
|
||||
ExtensionLibraryKind, ExtensionManifest, GrammarManifestEntry, parse_wasm_extension_version,
|
||||
};
|
||||
use anyhow::{Context as _, Result, bail};
|
||||
use anyhow::{Context as _, Result, bail, ensure};
|
||||
use async_compression::futures::bufread::GzipDecoder;
|
||||
use async_tar::Archive;
|
||||
use futures::io::BufReader;
|
||||
|
@ -12,6 +12,7 @@ use std::{
|
|||
env, fs, mem,
|
||||
path::{Path, PathBuf},
|
||||
process::Stdio,
|
||||
str::FromStr,
|
||||
sync::Arc,
|
||||
};
|
||||
use wasm_encoder::{ComponentSectionId, Encode as _, RawSection, Section as _};
|
||||
|
@ -97,6 +98,23 @@ impl ExtensionBuilder {
|
|||
log::info!("compiled Rust extension {}", extension_dir.display());
|
||||
}
|
||||
|
||||
let debug_adapters_dir = extension_dir.join("debug_adapter_schemas");
|
||||
if !extension_manifest.debug_adapters.is_empty() {
|
||||
ensure!(
|
||||
debug_adapters_dir.exists(),
|
||||
"Expected debug adapter schemas directory to exist"
|
||||
);
|
||||
}
|
||||
for debug_adapter_name in &extension_manifest.debug_adapters {
|
||||
let debug_adapter_schema_path = debug_adapters_dir.join(debug_adapter_name.as_ref());
|
||||
let debug_adapter_schema = fs::read_to_string(&debug_adapter_schema_path)
|
||||
.with_context(|| {
|
||||
format!("failed to read debug adapter schema for `{debug_adapter_name}`")
|
||||
})?;
|
||||
_ = serde_json::Value::from_str(&debug_adapter_schema).with_context(|| {
|
||||
format!("Debug adapter schema for `{debug_adapter_name}` is not a valid JSON")
|
||||
})?;
|
||||
}
|
||||
for (grammar_name, grammar_metadata) in &extension_manifest.grammars {
|
||||
let snake_cased_grammar_name = grammar_name.to_snake_case();
|
||||
if grammar_name.as_ref() != snake_cased_grammar_name.as_str() {
|
||||
|
|
|
@ -412,6 +412,7 @@ impl ExtensionIndexedDocsProviderProxy for ExtensionHostProxy {
|
|||
|
||||
pub trait ExtensionDebugAdapterProviderProxy: Send + Sync + 'static {
|
||||
fn register_debug_adapter(&self, extension: Arc<dyn Extension>, debug_adapter_name: Arc<str>);
|
||||
fn register_debug_locator(&self, extension: Arc<dyn Extension>, locator_name: Arc<str>);
|
||||
}
|
||||
|
||||
impl ExtensionDebugAdapterProviderProxy for ExtensionHostProxy {
|
||||
|
@ -422,4 +423,12 @@ impl ExtensionDebugAdapterProviderProxy for ExtensionHostProxy {
|
|||
|
||||
proxy.register_debug_adapter(extension, debug_adapter_name)
|
||||
}
|
||||
|
||||
fn register_debug_locator(&self, extension: Arc<dyn Extension>, locator_name: Arc<str>) {
|
||||
let Some(proxy) = self.debug_adapter_provider_proxy.read().clone() else {
|
||||
return;
|
||||
};
|
||||
|
||||
proxy.register_debug_locator(extension, locator_name)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -89,6 +89,8 @@ pub struct ExtensionManifest {
|
|||
pub capabilities: Vec<ExtensionCapability>,
|
||||
#[serde(default)]
|
||||
pub debug_adapters: Vec<Arc<str>>,
|
||||
#[serde(default)]
|
||||
pub debug_locators: Vec<Arc<str>>,
|
||||
}
|
||||
|
||||
impl ExtensionManifest {
|
||||
|
@ -277,6 +279,7 @@ fn manifest_from_old_manifest(
|
|||
snippets: None,
|
||||
capabilities: Vec::new(),
|
||||
debug_adapters: vec![],
|
||||
debug_locators: vec![],
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -305,6 +308,7 @@ mod tests {
|
|||
snippets: None,
|
||||
capabilities: vec![],
|
||||
debug_adapters: Default::default(),
|
||||
debug_locators: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,4 +2,7 @@ pub use dap::{
|
|||
StartDebuggingRequestArguments, StartDebuggingRequestArgumentsRequest,
|
||||
adapters::{DebugAdapterBinary, DebugTaskDefinition, TcpArguments},
|
||||
};
|
||||
pub use task::{AttachRequest, DebugRequest, LaunchRequest, TcpArgumentsTemplate};
|
||||
pub use task::{
|
||||
AttachRequest, BuildTaskDefinition, DebugRequest, DebugScenario, LaunchRequest,
|
||||
TaskTemplate as BuildTaskTemplate, TcpArgumentsTemplate,
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue