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:
parent
f96b29ca54
commit
a04c2ecff7
9 changed files with 93 additions and 76 deletions
|
@ -1,7 +1,7 @@
|
|||
pub mod extension_builder;
|
||||
mod extension_manifest;
|
||||
|
||||
use std::path::Path;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::sync::Arc;
|
||||
|
||||
use anyhow::{anyhow, bail, Context as _, Result};
|
||||
|
@ -11,6 +11,15 @@ use semantic_version::SemanticVersion;
|
|||
|
||||
pub use crate::extension_manifest::*;
|
||||
|
||||
#[async_trait]
|
||||
pub trait WorktreeDelegate: Send + Sync + 'static {
|
||||
fn id(&self) -> u64;
|
||||
fn root_path(&self) -> String;
|
||||
async fn read_text_file(&self, path: PathBuf) -> Result<String>;
|
||||
async fn which(&self, binary_name: String) -> Option<String>;
|
||||
async fn shell_env(&self) -> Vec<(String, String)>;
|
||||
}
|
||||
|
||||
pub trait KeyValueStoreDelegate: Send + Sync + 'static {
|
||||
fn insert(&self, key: String, docs: String) -> Task<Result<()>>;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue