From aed5e4997df26c99a186fb9a5b18da3bbc594ed3 Mon Sep 17 00:00:00 2001 From: Nayeem Rahman Date: Sun, 28 Jan 2024 21:56:45 +0000 Subject: [PATCH] chore(lsp): rename client-side command invocations (#22140) --- cli/lsp/capabilities.rs | 13 ++++------ cli/lsp/code_lens.rs | 30 +++++++++++------------ cli/lsp/language_server.rs | 19 +-------------- cli/tests/integration/lsp_tests.rs | 38 +++++++++++++++--------------- test_util/src/lsp.rs | 1 - 5 files changed, 39 insertions(+), 62 deletions(-) diff --git a/cli/lsp/capabilities.rs b/cli/lsp/capabilities.rs index 6ac093254c..650fea5718 100644 --- a/cli/lsp/capabilities.rs +++ b/cli/lsp/capabilities.rs @@ -39,7 +39,6 @@ fn code_action_capabilities( pub fn server_capabilities( client_capabilities: &ClientCapabilities, - enable_builtin_commands: bool, ) -> ServerCapabilities { let code_action_provider = code_action_capabilities(client_capabilities); ServerCapabilities { @@ -120,14 +119,10 @@ pub fn server_capabilities( document_link_provider: None, color_provider: None, execute_command_provider: Some(ExecuteCommandOptions { - commands: if enable_builtin_commands { - vec![ - "deno.cache".to_string(), - "deno.reloadImportRegistries".to_string(), - ] - } else { - vec![] - }, + commands: vec![ + "deno.cache".to_string(), + "deno.reloadImportRegistries".to_string(), + ], ..Default::default() }), call_hierarchy_provider: Some(CallHierarchyServerCapability::Simple(true)), diff --git a/cli/lsp/code_lens.rs b/cli/lsp/code_lens.rs index 707ff09463..adf1d5c63d 100644 --- a/cli/lsp/code_lens.rs +++ b/cli/lsp/code_lens.rs @@ -86,7 +86,7 @@ impl DenoTestCollector { range, command: Some(lsp::Command { title: title.to_string(), - command: "deno.test".to_string(), + command: "deno.client.test".to_string(), arguments: Some(vec![ json!(self.specifier), json!(name.as_ref()), @@ -282,7 +282,7 @@ async fn resolve_implementation_code_lens( }; lsp::Command { title, - command: "deno.showReferences".to_string(), + command: "deno.client.showReferences".to_string(), arguments: Some(vec![ json!(data.specifier), json!(code_lens.range.start), @@ -373,7 +373,7 @@ async fn resolve_references_code_lens( } else { lsp::Command { title, - command: "deno.showReferences".to_string(), + command: "deno.client.showReferences".to_string(), arguments: Some(vec![ json!(data.specifier), json!(code_lens.range.start), @@ -587,7 +587,7 @@ mod tests { }, command: Some(lsp::Command { title: "▶\u{fe0e} Run Test".to_string(), - command: "deno.test".to_string(), + command: "deno.client.test".to_string(), arguments: Some(vec![ json!("https://deno.land/x/mod.ts"), json!("test a"), @@ -611,7 +611,7 @@ mod tests { }, command: Some(lsp::Command { title: "Debug".to_string(), - command: "deno.test".to_string(), + command: "deno.client.test".to_string(), arguments: Some(vec![ json!("https://deno.land/x/mod.ts"), json!("test a"), @@ -635,7 +635,7 @@ mod tests { }, command: Some(lsp::Command { title: "▶\u{fe0e} Run Test".to_string(), - command: "deno.test".to_string(), + command: "deno.client.test".to_string(), arguments: Some(vec![ json!("https://deno.land/x/mod.ts"), json!("useFnName"), @@ -659,7 +659,7 @@ mod tests { }, command: Some(lsp::Command { title: "Debug".to_string(), - command: "deno.test".to_string(), + command: "deno.client.test".to_string(), arguments: Some(vec![ json!("https://deno.land/x/mod.ts"), json!("useFnName"), @@ -683,7 +683,7 @@ mod tests { }, command: Some(lsp::Command { title: "▶\u{fe0e} Run Test".to_string(), - command: "deno.test".to_string(), + command: "deno.client.test".to_string(), arguments: Some(vec![ json!("https://deno.land/x/mod.ts"), json!("test b"), @@ -707,7 +707,7 @@ mod tests { }, command: Some(lsp::Command { title: "Debug".to_string(), - command: "deno.test".to_string(), + command: "deno.client.test".to_string(), arguments: Some(vec![ json!("https://deno.land/x/mod.ts"), json!("test b"), @@ -731,7 +731,7 @@ mod tests { }, command: Some(lsp::Command { title: "▶\u{fe0e} Run Test".to_string(), - command: "deno.test".to_string(), + command: "deno.client.test".to_string(), arguments: Some(vec![ json!("https://deno.land/x/mod.ts"), json!("test ignore"), @@ -755,7 +755,7 @@ mod tests { }, command: Some(lsp::Command { title: "Debug".to_string(), - command: "deno.test".to_string(), + command: "deno.client.test".to_string(), arguments: Some(vec![ json!("https://deno.land/x/mod.ts"), json!("test ignore"), @@ -779,7 +779,7 @@ mod tests { }, command: Some(lsp::Command { title: "▶\u{fe0e} Run Test".to_string(), - command: "deno.test".to_string(), + command: "deno.client.test".to_string(), arguments: Some(vec![ json!("https://deno.land/x/mod.ts"), json!("test only"), @@ -803,7 +803,7 @@ mod tests { }, command: Some(lsp::Command { title: "Debug".to_string(), - command: "deno.test".to_string(), + command: "deno.client.test".to_string(), arguments: Some(vec![ json!("https://deno.land/x/mod.ts"), json!("test only"), @@ -827,7 +827,7 @@ mod tests { }, command: Some(lsp::Command { title: "▶\u{fe0e} Run Test".to_string(), - command: "deno.test".to_string(), + command: "deno.client.test".to_string(), arguments: Some(vec![ json!("https://deno.land/x/mod.ts"), json!("test template literal name"), @@ -851,7 +851,7 @@ mod tests { }, command: Some(lsp::Command { title: "Debug".to_string(), - command: "deno.test".to_string(), + command: "deno.client.test".to_string(), arguments: Some(vec![ json!("https://deno.land/x/mod.ts"), json!("test template literal name"), diff --git a/cli/lsp/language_server.rs b/cli/lsp/language_server.rs index f55610b1c5..31bd5ba8fb 100644 --- a/cli/lsp/language_server.rs +++ b/cli/lsp/language_server.rs @@ -1216,24 +1216,7 @@ impl Inner { parent_process_checker::start(parent_pid) } - // TODO(nayeemrmn): This flag exists to avoid breaking the extension for the - // 1.37.0 release. Eventually make this always true. - // See https://github.com/denoland/deno/pull/20111#issuecomment-1705776794. - let mut enable_builtin_commands = false; - if let Some(value) = ¶ms.initialization_options { - if let Some(object) = value.as_object() { - if let Some(value) = object.get("enableBuiltinCommands") { - if value.as_bool() == Some(true) { - enable_builtin_commands = true; - } - } - } - } - - let capabilities = capabilities::server_capabilities( - ¶ms.capabilities, - enable_builtin_commands, - ); + let capabilities = capabilities::server_capabilities(¶ms.capabilities); let version = format!( "{} ({}, {})", diff --git a/cli/tests/integration/lsp_tests.rs b/cli/tests/integration/lsp_tests.rs index 7a48dcda69..83ce5c98b3 100644 --- a/cli/tests/integration/lsp_tests.rs +++ b/cli/tests/integration/lsp_tests.rs @@ -3295,7 +3295,7 @@ fn lsp_code_lens() { }, "command": { "title": "1 reference", - "command": "deno.showReferences", + "command": "deno.client.showReferences", "arguments": [ "file:///a/file.ts", { "line": 0, "character": 6 }, @@ -3362,7 +3362,7 @@ fn lsp_code_lens() { }, "command": { "title": "2 references", - "command": "deno.showReferences", + "command": "deno.client.showReferences", "arguments": [ "file:///a/file.ts", { "line": 15, "character": 6 }, @@ -3490,7 +3490,7 @@ fn lsp_code_lens_impl() { }, "command": { "title": "1 implementation", - "command": "deno.showReferences", + "command": "deno.client.showReferences", "arguments": [ "file:///a/file.ts", { "line": 0, "character": 10 }, @@ -3568,7 +3568,7 @@ fn lsp_code_lens_test() { }, "command": { "title": "▶︎ Run Test", - "command": "deno.test", + "command": "deno.client.test", "arguments": [ "file:///a/file.ts", "test a", @@ -3582,7 +3582,7 @@ fn lsp_code_lens_test() { }, "command": { "title": "Debug", - "command": "deno.test", + "command": "deno.client.test", "arguments": [ "file:///a/file.ts", "test a", @@ -3596,7 +3596,7 @@ fn lsp_code_lens_test() { }, "command": { "title": "▶︎ Run Test", - "command": "deno.test", + "command": "deno.client.test", "arguments": [ "file:///a/file.ts", "test b", @@ -3610,7 +3610,7 @@ fn lsp_code_lens_test() { }, "command": { "title": "Debug", - "command": "deno.test", + "command": "deno.client.test", "arguments": [ "file:///a/file.ts", "test b", @@ -3624,7 +3624,7 @@ fn lsp_code_lens_test() { }, "command": { "title": "▶︎ Run Test", - "command": "deno.test", + "command": "deno.client.test", "arguments": [ "file:///a/file.ts", "test c", @@ -3638,7 +3638,7 @@ fn lsp_code_lens_test() { }, "command": { "title": "Debug", - "command": "deno.test", + "command": "deno.client.test", "arguments": [ "file:///a/file.ts", "test c", @@ -3652,7 +3652,7 @@ fn lsp_code_lens_test() { }, "command": { "title": "▶︎ Run Test", - "command": "deno.test", + "command": "deno.client.test", "arguments": [ "file:///a/file.ts", "test d", @@ -3666,7 +3666,7 @@ fn lsp_code_lens_test() { }, "command": { "title": "Debug", - "command": "deno.test", + "command": "deno.client.test", "arguments": [ "file:///a/file.ts", "test d", @@ -3680,7 +3680,7 @@ fn lsp_code_lens_test() { }, "command": { "title": "▶︎ Run Test", - "command": "deno.test", + "command": "deno.client.test", "arguments": [ "file:///a/file.ts", "test e", @@ -3694,7 +3694,7 @@ fn lsp_code_lens_test() { }, "command": { "title": "Debug", - "command": "deno.test", + "command": "deno.client.test", "arguments": [ "file:///a/file.ts", "test e", @@ -3708,7 +3708,7 @@ fn lsp_code_lens_test() { }, "command": { "title": "▶︎ Run Test", - "command": "deno.test", + "command": "deno.client.test", "arguments": [ "file:///a/file.ts", "test f", @@ -3722,7 +3722,7 @@ fn lsp_code_lens_test() { }, "command": { "title": "Debug", - "command": "deno.test", + "command": "deno.client.test", "arguments": [ "file:///a/file.ts", "test f", @@ -3736,7 +3736,7 @@ fn lsp_code_lens_test() { }, "command": { "title": "▶︎ Run Test", - "command": "deno.test", + "command": "deno.client.test", "arguments": [ "file:///a/file.ts", "test g", @@ -3750,7 +3750,7 @@ fn lsp_code_lens_test() { }, "command": { "title": "Debug", - "command": "deno.test", + "command": "deno.client.test", "arguments": [ "file:///a/file.ts", "test g", @@ -3764,7 +3764,7 @@ fn lsp_code_lens_test() { }, "command": { "title": "▶︎ Run Test", - "command": "deno.test", + "command": "deno.client.test", "arguments": [ "file:///a/file.ts", "test h", @@ -3778,7 +3778,7 @@ fn lsp_code_lens_test() { }, "command": { "title": "Debug", - "command": "deno.test", + "command": "deno.client.test", "arguments": [ "file:///a/file.ts", "test h", diff --git a/test_util/src/lsp.rs b/test_util/src/lsp.rs index d6a0bc3848..9b63b79cde 100644 --- a/test_util/src/lsp.rs +++ b/test_util/src/lsp.rs @@ -668,7 +668,6 @@ impl LspClient { self.initialize_with_config( do_build, json!({ "deno": { - "enableBuiltinCommands": true, "enable": true, "cache": null, "certificateStores": null,