extension: Add debug_adapters to extension manifest (#30676)

Also pass worktree to the get_dap_binary.

Release Notes:

- N/A
This commit is contained in:
Piotr Osiewicz 2025-05-20 11:01:33 +02:00 committed by GitHub
parent b1c7fa1dac
commit a092e2dc03
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
26 changed files with 147 additions and 59 deletions

View file

@ -61,7 +61,7 @@ impl CodeLldbDebugAdapter {
async fn fetch_latest_adapter_version(
&self,
delegate: &dyn DapDelegate,
delegate: &Arc<dyn DapDelegate>,
) -> Result<AdapterVersion> {
let release =
latest_github_release("vadimcn/codelldb", true, false, delegate.http_client()).await?;
@ -111,7 +111,7 @@ impl DebugAdapter for CodeLldbDebugAdapter {
async fn get_binary(
&self,
delegate: &dyn DapDelegate,
delegate: &Arc<dyn DapDelegate>,
config: &DebugTaskDefinition,
user_installed_path: Option<PathBuf>,
_: &mut AsyncApp,
@ -129,7 +129,7 @@ impl DebugAdapter for CodeLldbDebugAdapter {
self.name(),
version.clone(),
adapters::DownloadedFileType::Vsix,
delegate,
delegate.as_ref(),
)
.await?;
let version_path =

View file

@ -65,7 +65,7 @@ impl DebugAdapter for GdbDebugAdapter {
async fn get_binary(
&self,
delegate: &dyn DapDelegate,
delegate: &Arc<dyn DapDelegate>,
config: &DebugTaskDefinition,
user_installed_path: Option<std::path::PathBuf>,
_: &mut AsyncApp,
@ -76,6 +76,7 @@ impl DebugAdapter for GdbDebugAdapter {
let gdb_path = delegate
.which(OsStr::new("gdb"))
.await
.and_then(|p| p.to_str().map(|s| s.to_string()))
.ok_or(anyhow!("Could not find gdb in path"));

View file

@ -50,13 +50,14 @@ impl DebugAdapter for GoDebugAdapter {
async fn get_binary(
&self,
delegate: &dyn DapDelegate,
delegate: &Arc<dyn DapDelegate>,
config: &DebugTaskDefinition,
_user_installed_path: Option<PathBuf>,
_cx: &mut AsyncApp,
) -> Result<DebugAdapterBinary> {
let delve_path = delegate
.which(OsStr::new("dlv"))
.await
.and_then(|p| p.to_str().map(|p| p.to_string()))
.ok_or(anyhow!("Dlv not found in path"))?;

View file

@ -56,7 +56,7 @@ impl JsDebugAdapter {
async fn fetch_latest_adapter_version(
&self,
delegate: &dyn DapDelegate,
delegate: &Arc<dyn DapDelegate>,
) -> Result<AdapterVersion> {
let release = latest_github_release(
&format!("{}/{}", "microsoft", Self::ADAPTER_NPM_NAME),
@ -82,7 +82,7 @@ impl JsDebugAdapter {
async fn get_installed_binary(
&self,
delegate: &dyn DapDelegate,
delegate: &Arc<dyn DapDelegate>,
config: &DebugTaskDefinition,
user_installed_path: Option<PathBuf>,
_: &mut AsyncApp,
@ -139,7 +139,7 @@ impl DebugAdapter for JsDebugAdapter {
async fn get_binary(
&self,
delegate: &dyn DapDelegate,
delegate: &Arc<dyn DapDelegate>,
config: &DebugTaskDefinition,
user_installed_path: Option<PathBuf>,
cx: &mut AsyncApp,
@ -151,7 +151,7 @@ impl DebugAdapter for JsDebugAdapter {
self.name(),
version,
adapters::DownloadedFileType::GzipTar,
delegate,
delegate.as_ref(),
)
.await?;
}

View file

@ -40,7 +40,7 @@ impl PhpDebugAdapter {
async fn fetch_latest_adapter_version(
&self,
delegate: &dyn DapDelegate,
delegate: &Arc<dyn DapDelegate>,
) -> Result<AdapterVersion> {
let release = latest_github_release(
&format!("{}/{}", "xdebug", Self::ADAPTER_PACKAGE_NAME),
@ -66,7 +66,7 @@ impl PhpDebugAdapter {
async fn get_installed_binary(
&self,
delegate: &dyn DapDelegate,
delegate: &Arc<dyn DapDelegate>,
config: &DebugTaskDefinition,
user_installed_path: Option<PathBuf>,
_: &mut AsyncApp,
@ -126,7 +126,7 @@ impl DebugAdapter for PhpDebugAdapter {
async fn get_binary(
&self,
delegate: &dyn DapDelegate,
delegate: &Arc<dyn DapDelegate>,
config: &DebugTaskDefinition,
user_installed_path: Option<PathBuf>,
cx: &mut AsyncApp,
@ -138,7 +138,7 @@ impl DebugAdapter for PhpDebugAdapter {
self.name(),
version,
adapters::DownloadedFileType::Vsix,
delegate,
delegate.as_ref(),
)
.await?;
}

View file

@ -52,26 +52,26 @@ impl PythonDebugAdapter {
}
async fn fetch_latest_adapter_version(
&self,
delegate: &dyn DapDelegate,
delegate: &Arc<dyn DapDelegate>,
) -> Result<AdapterVersion> {
let github_repo = GithubRepo {
repo_name: Self::ADAPTER_PACKAGE_NAME.into(),
repo_owner: "microsoft".into(),
};
adapters::fetch_latest_adapter_version_from_github(github_repo, delegate).await
adapters::fetch_latest_adapter_version_from_github(github_repo, delegate.as_ref()).await
}
async fn install_binary(
&self,
version: AdapterVersion,
delegate: &dyn DapDelegate,
delegate: &Arc<dyn DapDelegate>,
) -> Result<()> {
let version_path = adapters::download_adapter_from_github(
self.name(),
version,
adapters::DownloadedFileType::Zip,
delegate,
delegate.as_ref(),
)
.await?;
@ -93,7 +93,7 @@ impl PythonDebugAdapter {
async fn get_installed_binary(
&self,
delegate: &dyn DapDelegate,
delegate: &Arc<dyn DapDelegate>,
config: &DebugTaskDefinition,
user_installed_path: Option<PathBuf>,
cx: &mut AsyncApp,
@ -128,14 +128,18 @@ impl PythonDebugAdapter {
let python_path = if let Some(toolchain) = toolchain {
Some(toolchain.path.to_string())
} else {
BINARY_NAMES
.iter()
.filter_map(|cmd| {
delegate
.which(OsStr::new(cmd))
.map(|path| path.to_string_lossy().to_string())
})
.find(|_| true)
let mut name = None;
for cmd in BINARY_NAMES {
name = delegate
.which(OsStr::new(cmd))
.await
.map(|path| path.to_string_lossy().to_string());
if name.is_some() {
break;
}
}
name
};
Ok(DebugAdapterBinary {
@ -172,7 +176,7 @@ impl DebugAdapter for PythonDebugAdapter {
async fn get_binary(
&self,
delegate: &dyn DapDelegate,
delegate: &Arc<dyn DapDelegate>,
config: &DebugTaskDefinition,
user_installed_path: Option<PathBuf>,
cx: &mut AsyncApp,

View file

@ -8,7 +8,7 @@ use dap::{
};
use gpui::{AsyncApp, SharedString};
use language::LanguageName;
use std::path::PathBuf;
use std::{path::PathBuf, sync::Arc};
use util::command::new_smol_command;
use crate::ToDap;
@ -32,7 +32,7 @@ impl DebugAdapter for RubyDebugAdapter {
async fn get_binary(
&self,
delegate: &dyn DapDelegate,
delegate: &Arc<dyn DapDelegate>,
definition: &DebugTaskDefinition,
_user_installed_path: Option<PathBuf>,
_cx: &mut AsyncApp,
@ -40,7 +40,7 @@ impl DebugAdapter for RubyDebugAdapter {
let adapter_path = paths::debug_adapters_dir().join(self.name().as_ref());
let mut rdbg_path = adapter_path.join("rdbg");
if !delegate.fs().is_file(&rdbg_path).await {
match delegate.which("rdbg".as_ref()) {
match delegate.which("rdbg".as_ref()).await {
Some(path) => rdbg_path = path,
None => {
delegate.output_to_console(
@ -76,7 +76,7 @@ impl DebugAdapter for RubyDebugAdapter {
format!("--port={}", port),
format!("--host={}", host),
];
if delegate.which(launch.program.as_ref()).is_some() {
if delegate.which(launch.program.as_ref()).await.is_some() {
arguments.push("--command".to_string())
}
arguments.push(launch.program);