summaryrefslogtreecommitdiff
path: root/cli/lsp/client.rs
diff options
context:
space:
mode:
authorKitson Kelly <me@kitsonkelly.com>2022-03-30 09:59:27 +1100
committerGitHub <noreply@github.com>2022-03-30 09:59:27 +1100
commit061090de7e95e8e7a97f3277bd1a72899ebd1570 (patch)
tree85fbf3ed3dc4cf51a15c2baaf8257a47149c43ef /cli/lsp/client.rs
parent4a0b2c28a15d76c0c40bf07c3753dfbcce4dace1 (diff)
feat(lsp): add experimental testing API (#13798)
Ref: denoland/vscode_deno#629
Diffstat (limited to 'cli/lsp/client.rs')
-rw-r--r--cli/lsp/client.rs40
1 files changed, 40 insertions, 0 deletions
diff --git a/cli/lsp/client.rs b/cli/lsp/client.rs
index 92a5dfffb..b5728961f 100644
--- a/cli/lsp/client.rs
+++ b/cli/lsp/client.rs
@@ -16,6 +16,14 @@ use crate::lsp::repl::get_repl_workspace_settings;
use super::config::SpecifierSettings;
use super::config::SETTINGS_SECTION;
use super::lsp_custom;
+use super::testing::lsp_custom as testing_lsp_custom;
+
+#[derive(Debug)]
+pub enum TestingNotification {
+ Module(testing_lsp_custom::TestModuleNotificationParams),
+ DeleteModule(testing_lsp_custom::TestModuleDeleteNotificationParams),
+ Progress(testing_lsp_custom::TestRunProgressParams),
+}
#[derive(Clone)]
pub struct Client(Arc<dyn ClientTrait>);
@@ -51,6 +59,10 @@ impl Client {
self.0.send_registry_state_notification(params).await;
}
+ pub fn send_test_notification(&self, params: TestingNotification) {
+ self.0.send_test_notification(params);
+ }
+
pub async fn specifier_configurations(
&self,
specifiers: Vec<lsp::Url>,
@@ -118,6 +130,7 @@ trait ClientTrait: Send + Sync {
&self,
params: lsp_custom::RegistryStateNotificationParams,
) -> AsyncReturn<()>;
+ fn send_test_notification(&self, params: TestingNotification);
fn specifier_configurations(
&self,
uris: Vec<lsp::Url>,
@@ -164,6 +177,31 @@ impl ClientTrait for LspowerClient {
})
}
+ fn send_test_notification(&self, notification: TestingNotification) {
+ let client = self.0.clone();
+ tokio::task::spawn(async move {
+ match notification {
+ TestingNotification::Module(params) => {
+ client
+ .send_custom_notification::<testing_lsp_custom::TestModuleNotification>(
+ params,
+ )
+ .await
+ }
+ TestingNotification::DeleteModule(params) => client
+ .send_custom_notification::<testing_lsp_custom::TestModuleDeleteNotification>(
+ params,
+ )
+ .await,
+ TestingNotification::Progress(params) => client
+ .send_custom_notification::<testing_lsp_custom::TestRunProgressNotification>(
+ params,
+ )
+ .await,
+ }
+ });
+ }
+
fn specifier_configurations(
&self,
uris: Vec<lsp::Url>,
@@ -260,6 +298,8 @@ impl ClientTrait for ReplClient {
Box::pin(future::ready(()))
}
+ fn send_test_notification(&self, _params: TestingNotification) {}
+
fn specifier_configurations(
&self,
uris: Vec<lsp::Url>,