Decouple extension Worktree resource from LspAdapterDelegate (#20611)

This PR decouples the extension `Worktree` resource from the
`LspAdapterDelegate`.

We now have a `WorktreeDelegate` trait that corresponds to the methods
on the resource.

We then create a `WorktreeDelegateAdapter` that can wrap an
`LspAdapterDelegate` and implement the `WorktreeDelegate` trait.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2024-11-13 12:24:27 -05:00 committed by GitHub
parent f96b29ca54
commit a04c2ecff7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 93 additions and 76 deletions

View file

@ -5,6 +5,7 @@ use assistant_slash_command::{
ArgumentCompletion, SlashCommand, SlashCommandOutput, SlashCommandOutputSection,
SlashCommandResult,
};
use extension_host::extension_lsp_adapter::WorktreeDelegateAdapter;
use futures::FutureExt as _;
use gpui::{Task, WeakView, WindowContext};
use language::{BufferSnapshot, LspAdapterDelegate};
@ -97,6 +98,8 @@ impl SlashCommand for ExtensionSlashCommand {
move |extension, store| {
async move {
let resource = if let Some(delegate) = delegate {
let delegate =
Arc::new(WorktreeDelegateAdapter(delegate.clone())) as _;
Some(store.data_mut().table().push(delegate)?)
} else {
None