Make LspAdapter::process_diagnostics synchronous
Co-authored-by: Nathan <nathan@zed.dev>
This commit is contained in:
parent
e3a4d174de
commit
4e33654aba
3 changed files with 19 additions and 28 deletions
|
@ -182,8 +182,8 @@ impl CachedLspAdapter {
|
||||||
self.adapter.workspace_configuration(cx)
|
self.adapter.workspace_configuration(cx)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn process_diagnostics(&self, params: &mut lsp::PublishDiagnosticsParams) {
|
pub fn process_diagnostics(&self, params: &mut lsp::PublishDiagnosticsParams) {
|
||||||
self.adapter.process_diagnostics(params).await
|
self.adapter.process_diagnostics(params)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn process_completion(&self, completion_item: &mut lsp::CompletionItem) {
|
pub async fn process_completion(&self, completion_item: &mut lsp::CompletionItem) {
|
||||||
|
@ -262,7 +262,7 @@ pub trait LspAdapter: 'static + Send + Sync {
|
||||||
container_dir: PathBuf,
|
container_dir: PathBuf,
|
||||||
) -> Option<LanguageServerBinary>;
|
) -> Option<LanguageServerBinary>;
|
||||||
|
|
||||||
async fn process_diagnostics(&self, _: &mut lsp::PublishDiagnosticsParams) {}
|
fn process_diagnostics(&self, _: &mut lsp::PublishDiagnosticsParams) {}
|
||||||
|
|
||||||
async fn process_completion(&self, _: &mut lsp::CompletionItem) {}
|
async fn process_completion(&self, _: &mut lsp::CompletionItem) {}
|
||||||
|
|
||||||
|
@ -1487,12 +1487,6 @@ impl Language {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn process_diagnostics(&self, diagnostics: &mut lsp::PublishDiagnosticsParams) {
|
|
||||||
for adapter in &self.adapters {
|
|
||||||
adapter.process_diagnostics(diagnostics).await;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn process_completion(self: &Arc<Self>, completion: &mut lsp::CompletionItem) {
|
pub async fn process_completion(self: &Arc<Self>, completion: &mut lsp::CompletionItem) {
|
||||||
for adapter in &self.adapters {
|
for adapter in &self.adapters {
|
||||||
adapter.process_completion(completion).await;
|
adapter.process_completion(completion).await;
|
||||||
|
@ -1756,7 +1750,7 @@ impl LspAdapter for Arc<FakeLspAdapter> {
|
||||||
unreachable!();
|
unreachable!();
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn process_diagnostics(&self, _: &mut lsp::PublishDiagnosticsParams) {}
|
fn process_diagnostics(&self, _: &mut lsp::PublishDiagnosticsParams) {}
|
||||||
|
|
||||||
async fn disk_based_diagnostic_sources(&self) -> Vec<String> {
|
async fn disk_based_diagnostic_sources(&self) -> Vec<String> {
|
||||||
self.disk_based_diagnostics_sources.clone()
|
self.disk_based_diagnostics_sources.clone()
|
||||||
|
|
|
@ -2769,24 +2769,21 @@ impl Project {
|
||||||
language_server
|
language_server
|
||||||
.on_notification::<lsp::notification::PublishDiagnostics, _>({
|
.on_notification::<lsp::notification::PublishDiagnostics, _>({
|
||||||
let adapter = adapter.clone();
|
let adapter = adapter.clone();
|
||||||
move |mut params, cx| {
|
move |mut params, mut cx| {
|
||||||
let this = this;
|
let this = this;
|
||||||
let adapter = adapter.clone();
|
let adapter = adapter.clone();
|
||||||
cx.spawn(|mut cx| async move {
|
adapter.process_diagnostics(&mut params);
|
||||||
adapter.process_diagnostics(&mut params).await;
|
if let Some(this) = this.upgrade(&cx) {
|
||||||
if let Some(this) = this.upgrade(&cx) {
|
this.update(&mut cx, |this, cx| {
|
||||||
this.update(&mut cx, |this, cx| {
|
this.update_diagnostics(
|
||||||
this.update_diagnostics(
|
server_id,
|
||||||
server_id,
|
params,
|
||||||
params,
|
&adapter.disk_based_diagnostic_sources,
|
||||||
&adapter.disk_based_diagnostic_sources,
|
cx,
|
||||||
cx,
|
)
|
||||||
)
|
.log_err();
|
||||||
.log_err();
|
});
|
||||||
});
|
}
|
||||||
}
|
|
||||||
})
|
|
||||||
.detach();
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.detach();
|
.detach();
|
||||||
|
|
|
@ -102,7 +102,7 @@ impl LspAdapter for RustLspAdapter {
|
||||||
Some("rust-analyzer/flycheck".into())
|
Some("rust-analyzer/flycheck".into())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn process_diagnostics(&self, params: &mut lsp::PublishDiagnosticsParams) {
|
fn process_diagnostics(&self, params: &mut lsp::PublishDiagnosticsParams) {
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
static ref REGEX: Regex = Regex::new("(?m)`([^`]+)\n`$").unwrap();
|
static ref REGEX: Regex = Regex::new("(?m)`([^`]+)\n`$").unwrap();
|
||||||
}
|
}
|
||||||
|
@ -310,7 +310,7 @@ mod tests {
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
RustLspAdapter.process_diagnostics(&mut params).await;
|
RustLspAdapter.process_diagnostics(&mut params);
|
||||||
|
|
||||||
assert_eq!(params.diagnostics[0].message, "use of moved value `a`");
|
assert_eq!(params.diagnostics[0].message, "use of moved value `a`");
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue