summaryrefslogtreecommitdiff
path: root/cli/lsp/client.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/client.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/client.rs')
-rw-r--r--cli/lsp/client.rs34
1 files changed, 34 insertions, 0 deletions
diff --git a/cli/lsp/client.rs b/cli/lsp/client.rs
index 4923a4585..5f1a7fcef 100644
--- a/cli/lsp/client.rs
+++ b/cli/lsp/client.rs
@@ -62,6 +62,20 @@ impl Client {
});
}
+ /// This notification is sent to the client during internal testing
+ /// purposes only in order to let the test client know when the latest
+ /// diagnostics have been published.
+ pub fn send_diagnostic_batch_notification(
+ &self,
+ params: lsp_custom::DiagnosticBatchNotificationParams,
+ ) {
+ // do on a task in case the caller currently is in the lsp lock
+ let client = self.0.clone();
+ spawn(async move {
+ client.send_diagnostic_batch_notification(params).await;
+ });
+ }
+
pub fn send_test_notification(&self, params: TestingNotification) {
// do on a task in case the caller currently is in the lsp lock
let client = self.0.clone();
@@ -160,6 +174,10 @@ trait ClientTrait: Send + Sync {
&self,
params: lsp_custom::RegistryStateNotificationParams,
);
+ async fn send_diagnostic_batch_notification(
+ &self,
+ params: lsp_custom::DiagnosticBatchNotificationParams,
+ );
async fn send_test_notification(&self, params: TestingNotification);
async fn specifier_configurations(
&self,
@@ -197,6 +215,16 @@ impl ClientTrait for TowerClient {
.await
}
+ async fn send_diagnostic_batch_notification(
+ &self,
+ params: lsp_custom::DiagnosticBatchNotificationParams,
+ ) {
+ self
+ .0
+ .send_notification::<lsp_custom::DiagnosticBatchNotification>(params)
+ .await
+ }
+
async fn send_test_notification(&self, notification: TestingNotification) {
match notification {
TestingNotification::Module(params) => {
@@ -311,6 +339,12 @@ impl ClientTrait for ReplClient {
) {
}
+ async fn send_diagnostic_batch_notification(
+ &self,
+ _params: lsp_custom::DiagnosticBatchNotificationParams,
+ ) {
+ }
+
async fn send_test_notification(&self, _params: TestingNotification) {}
async fn specifier_configurations(