1use std::{path::PathBuf, sync::Arc};
2
3use anyhow::Result;
4use async_trait::async_trait;
5use dap::adapters::{
6 DapDelegate, DebugAdapter, DebugAdapterBinary, DebugAdapterName, DebugTaskDefinition,
7};
8use extension::Extension;
9use gpui::AsyncApp;
10
11pub(crate) struct ExtensionDapAdapter {
12 extension: Arc<dyn Extension>,
13 debug_adapter_name: Arc<str>,
14}
15
16impl ExtensionDapAdapter {
17 pub(crate) fn new(
18 extension: Arc<dyn extension::Extension>,
19 debug_adapter_name: Arc<str>,
20 ) -> Self {
21 Self {
22 extension,
23 debug_adapter_name,
24 }
25 }
26}
27
28#[async_trait(?Send)]
29impl DebugAdapter for ExtensionDapAdapter {
30 fn name(&self) -> DebugAdapterName {
31 self.debug_adapter_name.as_ref().into()
32 }
33
34 async fn get_binary(
35 &self,
36 _: &dyn DapDelegate,
37 config: &DebugTaskDefinition,
38 user_installed_path: Option<PathBuf>,
39 _cx: &mut AsyncApp,
40 ) -> Result<DebugAdapterBinary> {
41 self.extension
42 .get_dap_binary(
43 self.debug_adapter_name.clone(),
44 config.clone(),
45 user_installed_path,
46 )
47 .await
48 }
49}