summaryrefslogtreecommitdiff
path: root/test_util/src/lsp.rs
diff options
context:
space:
mode:
authorNayeem Rahman <nayeemrmn99@gmail.com>2023-09-21 06:46:39 +0100
committerGitHub <noreply@github.com>2023-09-21 06:46:39 +0100
commita4ac6a3f5f1b02b5290ab603d76b5cd9030731ca (patch)
tree6abbd056b42355f818383393cebe571072e0253b /test_util/src/lsp.rs
parent0981aefbdce4c0be961f6447bf68069c518227ef (diff)
refactor(lsp): store language sections in WorkspaceSettings (#20593)
When sending configuration requests to the client, reads `javascript` and `typescript` sections in addition to `deno`. The LSP's initialization options now accepts `javascript` and `typescript` namespaces.
Diffstat (limited to 'test_util/src/lsp.rs')
-rw-r--r--test_util/src/lsp.rs23
1 files changed, 16 insertions, 7 deletions
diff --git a/test_util/src/lsp.rs b/test_util/src/lsp.rs
index 2af27e8d4..72d27f6d0 100644
--- a/test_util/src/lsp.rs
+++ b/test_util/src/lsp.rs
@@ -685,9 +685,9 @@ impl LspClient {
) {
self.initialize_with_config(
do_build,
- json!([{
+ json!({"deno":{
"enable": true
- }]),
+ }}),
)
}
@@ -709,18 +709,18 @@ impl LspClient {
self.write_notification("initialized", json!({}));
self.config = config;
if self.supports_workspace_configuration {
- self.handle_configuration_request(self.config.clone());
+ self.handle_configuration_request(&self.config.clone());
}
}
pub fn did_open(&mut self, params: Value) -> CollectedDiagnostics {
- self.did_open_with_config(params, self.config.clone())
+ self.did_open_with_config(params, &self.config.clone())
}
pub fn did_open_with_config(
&mut self,
params: Value,
- config: Value,
+ config: &Value,
) -> CollectedDiagnostics {
self.did_open_raw(params);
if self.supports_workspace_configuration {
@@ -733,9 +733,18 @@ impl LspClient {
self.write_notification("textDocument/didOpen", params);
}
- pub fn handle_configuration_request(&mut self, result: Value) {
- let (id, method, _) = self.read_request::<Value>();
+ pub fn handle_configuration_request(&mut self, settings: &Value) {
+ let (id, method, args) = self.read_request::<Value>();
assert_eq!(method, "workspace/configuration");
+ let params = args.as_ref().unwrap().as_object().unwrap();
+ let items = params.get("items").unwrap().as_array().unwrap();
+ let settings_object = settings.as_object().unwrap();
+ let mut result = vec![];
+ for item in items {
+ let item = item.as_object().unwrap();
+ let section = item.get("section").unwrap().as_str().unwrap();
+ result.push(settings_object.get(section).cloned().unwrap_or_default());
+ }
self.write_response(id, result);
}