ZIm/crates/debug_adapter_extension/src/extension_locator_adapter.rs
feeiyu 2246b01c4b
Allow remote loading for DAP-only extensions (#33981)
Closes #ISSUE


![image](https://github.com/user-attachments/assets/8e1766e4-5d89-4263-875d-ad0dff5c55c2)


Release Notes:

- Allow remote loading for DAP-only extensions
2025-07-06 14:52:16 +02:00

52 lines
1.5 KiB
Rust

use anyhow::Result;
use async_trait::async_trait;
use dap::{DapLocator, DebugRequest, adapters::DebugAdapterName};
use extension::Extension;
use gpui::SharedString;
use std::sync::Arc;
use task::{DebugScenario, SpawnInTerminal, TaskTemplate};
pub(crate) struct ExtensionLocatorAdapter {
extension: Arc<dyn Extension>,
locator_name: SharedString,
}
impl ExtensionLocatorAdapter {
pub(crate) fn new(extension: Arc<dyn extension::Extension>, locator_name: Arc<str>) -> Self {
Self {
extension,
locator_name: SharedString::from(locator_name),
}
}
}
#[async_trait]
impl DapLocator for ExtensionLocatorAdapter {
fn name(&self) -> SharedString {
self.locator_name.clone()
}
/// Determines whether this locator can generate debug target for given task.
async fn create_scenario(
&self,
build_config: &TaskTemplate,
resolved_label: &str,
adapter: &DebugAdapterName,
) -> Option<DebugScenario> {
self.extension
.dap_locator_create_scenario(
self.locator_name.as_ref().to_owned(),
build_config.clone(),
resolved_label.to_owned(),
adapter.0.as_ref().to_owned(),
)
.await
.ok()
.flatten()
}
async fn run(&self, build_config: SpawnInTerminal) -> Result<DebugRequest> {
self.extension
.run_dap_locator(self.locator_name.as_ref().to_owned(), build_config)
.await
}
}