Going to move LspAdapter from trait to struct

This commit is contained in:
Isaac Clayton 2022-07-06 10:14:49 +02:00
parent e4a680f47b
commit 602fe14aa4
2 changed files with 20 additions and 0 deletions

View file

@ -65,6 +65,23 @@ pub struct LanguageServerName(pub Arc<str>);
use async_trait::async_trait; use async_trait::async_trait;
// pub struct LspAdapter {
// name: LanguageServerName,
// adapter: Arc<dyn LspAdapter>,
// }
// impl LspAdapter {
// async fn new(adapter: Arc<dyn LspAdapter>) -> Self {
// let name = adapter.name().await;
// LspAdapter { name, adapter }
// }
// fn name(&self) -> LanguageServerName {
// self.name
// }
// }
#[async_trait] #[async_trait]
pub trait LspAdapter: 'static + Send + Sync { pub trait LspAdapter: 'static + Send + Sync {
async fn name(&self) -> LanguageServerName; async fn name(&self) -> LanguageServerName;

View file

@ -1787,6 +1787,7 @@ impl Project {
))?, ))?,
} }
cx.subscribe(buffer, |this, buffer, event, cx| { cx.subscribe(buffer, |this, buffer, event, cx| {
// TODO(isaac): should this be done in the background?
this.on_buffer_event(buffer, event, cx).await; this.on_buffer_event(buffer, event, cx).await;
}) })
.detach(); .detach();
@ -3310,6 +3311,7 @@ impl Project {
return Ok(Default::default()); return Ok(Default::default());
}; };
// TODO(isaac): also use join_all
struct PartialSymbol { struct PartialSymbol {
source_worktree_id: WorktreeId, source_worktree_id: WorktreeId,
worktree_id: WorktreeId, worktree_id: WorktreeId,
@ -3537,6 +3539,7 @@ impl Project {
Default::default() Default::default()
}; };
// TODO(isaac): use futures::future::join_all
struct PartialCompletion { struct PartialCompletion {
pub old_range: Range<Anchor>, pub old_range: Range<Anchor>,
pub new_text: String, pub new_text: String,