summaryrefslogtreecommitdiff
path: root/cli/lsp/language_server.rs
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2023-05-25 23:01:33 -0400
committerGitHub <noreply@github.com>2023-05-26 05:01:33 +0200
commit89026abe395c22eb2ace4ea5f948189daa1dadf1 (patch)
tree8f2ecedf1b83508414034e0ca04852fcd2ca1f6d /cli/lsp/language_server.rs
parent0a3d355ce6311df6519dbffe7394ed2682d8a633 (diff)
chore(lsp/tests): diagnostic synchronization (#19264)
Fixes the flaky lsp test by having better synchronization of diagnostics between the client and server for testing purposes.
Diffstat (limited to 'cli/lsp/language_server.rs')
-rw-r--r--cli/lsp/language_server.rs27
1 files changed, 22 insertions, 5 deletions
diff --git a/cli/lsp/language_server.rs b/cli/lsp/language_server.rs
index 9a2b067c6..7c4191c82 100644
--- a/cli/lsp/language_server.rs
+++ b/cli/lsp/language_server.rs
@@ -46,6 +46,7 @@ use super::completions;
use super::config::Config;
use super::config::SETTINGS_SECTION;
use super::diagnostics;
+use super::diagnostics::DiagnosticServerUpdateMessage;
use super::diagnostics::DiagnosticsServer;
use super::documents::to_hover_text;
use super::documents::to_lsp_range;
@@ -342,6 +343,22 @@ impl LanguageServer {
}
}
+ /// This request is only used by the lsp integration tests to
+ /// coordinate the tests receiving the latest diagnostics.
+ pub async fn latest_diagnostic_batch_index_request(
+ &self,
+ ) -> LspResult<Option<Value>> {
+ Ok(
+ self
+ .0
+ .read()
+ .await
+ .diagnostics_server
+ .latest_batch_index()
+ .map(|v| v.into()),
+ )
+ }
+
pub async fn performance_request(&self) -> LspResult<Option<Value>> {
Ok(Some(self.0.read().await.get_performance()))
}
@@ -2932,11 +2949,11 @@ impl Inner {
}
fn send_diagnostics_update(&self) {
- let snapshot = (
- self.snapshot(),
- self.config.snapshot(),
- self.lint_options.clone(),
- );
+ let snapshot = DiagnosticServerUpdateMessage {
+ snapshot: self.snapshot(),
+ config: self.config.snapshot(),
+ lint_options: self.lint_options.clone(),
+ };
if let Err(err) = self.diagnostics_server.update(snapshot) {
error!("Cannot update diagnostics: {}", err);
}