diff options
author | Nayeem Rahman <nayeemrmn99@gmail.com> | 2023-09-26 21:57:14 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-26 21:57:14 +0100 |
commit | cb154d6afa3d260e3b281404155d04806aa2014c (patch) | |
tree | 57a1aa4396dc482ef605cdb8b53ab4b535170057 /cli | |
parent | dcb00bb9b8bf39f0caa6bb87b6b11e1344803bb9 (diff) |
chore(lsp): bump tower-lsp to 0.20.0 (#20693)
Diffstat (limited to 'cli')
-rw-r--r-- | cli/lsp/capabilities.rs | 3 | ||||
-rw-r--r-- | cli/lsp/language_server.rs | 18 | ||||
-rw-r--r-- | cli/lsp/lsp_custom.rs | 3 | ||||
-rw-r--r-- | cli/lsp/mod.rs | 5 | ||||
-rw-r--r-- | cli/lsp/tsc.rs | 1 | ||||
-rw-r--r-- | cli/tests/integration/lsp_tests.rs | 180 | ||||
-rw-r--r-- | cli/tests/integration/npm_tests.rs | 7 |
7 files changed, 85 insertions, 132 deletions
diff --git a/cli/lsp/capabilities.rs b/cli/lsp/capabilities.rs index f342b41b0..8b624eafc 100644 --- a/cli/lsp/capabilities.rs +++ b/cli/lsp/capabilities.rs @@ -153,5 +153,8 @@ pub fn server_capabilities( })), inlay_hint_provider: Some(OneOf::Left(true)), position_encoding: None, + // TODO(nayeemrmn): Support pull-based diagnostics. + diagnostic_provider: None, + inline_value_provider: None, } } diff --git a/cli/lsp/language_server.rs b/cli/lsp/language_server.rs index c72239aa7..ad0da1c57 100644 --- a/cli/lsp/language_server.rs +++ b/cli/lsp/language_server.rs @@ -381,13 +381,6 @@ impl LanguageServer { } } - pub async fn inlay_hint( - &self, - params: InlayHintParams, - ) -> LspResult<Option<Vec<InlayHint>>> { - self.0.read().await.inlay_hint(params).await - } - pub async fn virtual_text_document( &self, params: Option<Value>, @@ -3156,7 +3149,9 @@ impl tower_lsp::LanguageServer for LanguageServer { // are interested in. let options = DidChangeWatchedFilesRegistrationOptions { watchers: vec![FileSystemWatcher { - glob_pattern: "**/*.{json,jsonc,lock}".to_string(), + glob_pattern: GlobPattern::String( + "**/*.{json,jsonc,lock}".to_string(), + ), kind: None, }], }; @@ -3417,6 +3412,13 @@ impl tower_lsp::LanguageServer for LanguageServer { self.0.read().await.hover(params).await } + async fn inlay_hint( + &self, + params: InlayHintParams, + ) -> LspResult<Option<Vec<InlayHint>>> { + self.0.read().await.inlay_hint(params).await + } + async fn code_action( &self, params: CodeActionParams, diff --git a/cli/lsp/lsp_custom.rs b/cli/lsp/lsp_custom.rs index 24c4bc131..d9dbae8a4 100644 --- a/cli/lsp/lsp_custom.rs +++ b/cli/lsp/lsp_custom.rs @@ -13,9 +13,6 @@ pub const VIRTUAL_TEXT_DOCUMENT: &str = "deno/virtualTextDocument"; pub const LATEST_DIAGNOSTIC_BATCH_INDEX: &str = "deno/internalLatestDiagnosticBatchIndex"; -// While lsp_types supports inlay hints currently, tower_lsp does not. -pub const INLAY_HINT: &str = "textDocument/inlayHint"; - #[derive(Debug, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct CacheParams { diff --git a/cli/lsp/mod.rs b/cli/lsp/mod.rs index ed3971dc8..3ef19173b 100644 --- a/cli/lsp/mod.rs +++ b/cli/lsp/mod.rs @@ -42,6 +42,8 @@ pub async fn start() -> Result<(), AnyError> { let builder = LspService::build(|client| { language_server::LanguageServer::new(client::Client::from_tower(client)) }) + // TODO(nayeemrmn): The extension has replaced this with the `deno.cache` + // command as of vscode_deno 3.21.0 / 2023.09.05. Remove this eventually. .custom_method(lsp_custom::CACHE_REQUEST, LanguageServer::cache_request) .custom_method( lsp_custom::PERFORMANCE_REQUEST, @@ -60,8 +62,7 @@ pub async fn start() -> Result<(), AnyError> { .custom_method( lsp_custom::VIRTUAL_TEXT_DOCUMENT, LanguageServer::virtual_text_document, - ) - .custom_method(lsp_custom::INLAY_HINT, LanguageServer::inlay_hint); + ); let builder = if should_send_diagnostic_batch_index_notifications() { builder.custom_method( diff --git a/cli/lsp/tsc.rs b/cli/lsp/tsc.rs index f2b9f5634..9a33ff5f9 100644 --- a/cli/lsp/tsc.rs +++ b/cli/lsp/tsc.rs @@ -2993,6 +2993,7 @@ impl OutliningSpan { Some(range.end.character) }, kind: self.get_folding_range_kind(&self.kind), + collapsed_text: None, } } diff --git a/cli/tests/integration/lsp_tests.rs b/cli/tests/integration/lsp_tests.rs index 336304db7..1d0e482fa 100644 --- a/cli/tests/integration/lsp_tests.rs +++ b/cli/tests/integration/lsp_tests.rs @@ -235,10 +235,7 @@ fn lsp_import_map_remote() { "workspace/executeCommand", json!({ "command": "deno.cache", - "arguments": [ - [], - temp_dir.uri().join("file.ts").unwrap(), - ], + "arguments": [[], temp_dir.uri().join("file.ts").unwrap()], }), ); @@ -1966,12 +1963,10 @@ fn lsp_hover_dependency() { }), ); client.write_request( - "deno/cache", + "workspace/executeCommand", json!({ - "referrer": { - "uri": "file:///a/file.ts", - }, - "uris": [], + "command": "deno.cache", + "arguments": [[], "file:///a/file.ts"], }), ); let res = client.write_request( @@ -2199,15 +2194,12 @@ fn lsp_hover_typescript_types() { }), ); client.write_request( - "deno/cache", + "workspace/executeCommand", json!({ - "referrer": { - "uri": "file:///a/file.ts", - }, - "uris": [ - { - "uri": "http://127.0.0.1:4545/xTypeScriptTypes.js", - } + "command": "deno.cache", + "arguments": [ + ["http://127.0.0.1:4545/xTypeScriptTypes.js"], + "file:///a/file.ts", ], }), ); @@ -5809,18 +5801,13 @@ fn lsp_npm_completions_auto_import_and_quick_fix_no_import_map() { }), ); client.write_request( - "deno/cache", + "workspace/executeCommand", json!({ - "referrer": { - "uri": "file:///a/file.ts", - }, - "uris": [ - { - "uri": "npm:@denotest/types-exports-subpaths@1/client", - }, { - "uri": "npm:chalk@5.0", - } - ] + "command": "deno.cache", + "arguments": [ + ["npm:@denotest/types-exports-subpaths@1/client", "npm:chalk@5.0"], + "file:///a/file.ts", + ], }), ); @@ -6123,22 +6110,18 @@ fn lsp_completions_auto_import_and_quick_fix_with_import_map() { }), ); client.write_request( - "deno/cache", + "workspace/executeCommand", json!({ - "referrer": { - "uri": "file:///a/file.ts", - }, - "uris": [ - { - "uri": "npm:@denotest/types-exports-subpaths@1/client", - }, { - "uri": "npm:chalk@^5.0", - }, { - "uri": "npm:chalk@~5", - }, { - "uri": "http://localhost:4545/subdir/print_hello.ts", - } - ] + "command": "deno.cache", + "arguments": [ + [ + "npm:@denotest/types-exports-subpaths@1/client", + "npm:chalk@^5.0", + "npm:chalk@~5", + "http://localhost:4545/subdir/print_hello.ts", + ], + "file:///a/file.ts", + ], }), ); @@ -6643,18 +6626,13 @@ fn lsp_completions_npm() { }), ); client.write_request( - "deno/cache", + "workspace/executeCommand", json!({ - "referrer": { - "uri": "file:///a/file.ts", - }, - "uris": [ - { - "uri": "npm:@denotest/cjs-default-export", - }, { - "uri": "npm:chalk", - } - ] + "command": "deno.cache", + "arguments": [ + ["npm:@denotest/cjs-default-export", "npm:chalk"], + "file:///a/file.ts", + ], }), ); @@ -7021,16 +6999,10 @@ fn lsp_completions_node_specifier() { ); client.write_request( - "deno/cache", + "workspace/executeCommand", json!({ - "referrer": { - "uri": "file:///a/file.ts", - }, - "uris": [ - { - "uri": "npm:@types/node", - } - ] + "command": "deno.cache", + "arguments": [["npm:@types/node"], "file:///a/file.ts"], }), ); @@ -7265,12 +7237,10 @@ fn lsp_cache_location() { })); assert_eq!(diagnostics.all().len(), 6); client.write_request( - "deno/cache", + "workspace/executeCommand", json!({ - "referrer": { - "uri": "file:///a/file.ts", - }, - "uris": [], + "command": "deno.cache", + "arguments": [[], "file:///a/file.ts"], }), ); let res = client.write_request( @@ -7361,12 +7331,10 @@ fn lsp_tls_cert() { let diagnostics = diagnostics.all(); assert_eq!(diagnostics.len(), 6); client.write_request( - "deno/cache", + "workspace/executeCommand", json!({ - "referrer": { - "uri": "file:///a/file.ts", - }, - "uris": [], + "command": "deno.cache", + "arguments": [[], "file:///a/file.ts"], }), ); let res = client.write_request( @@ -7435,15 +7403,12 @@ fn lsp_diagnostics_warn_redirect() { }), ); client.write_request( - "deno/cache", + "workspace/executeCommand", json!({ - "referrer": { - "uri": "file:///a/file.ts", - }, - "uris": [ - { - "uri": "http://127.0.0.1:4545/x_deno_warning.js", - } + "command": "deno.cache", + "arguments": [ + ["http://127.0.0.1:4545/x_deno_warning.js"], + "file:///a/file.ts", ], }), ); @@ -7514,15 +7479,12 @@ fn lsp_redirect_quick_fix() { }), ); client.write_request( - "deno/cache", + "workspace/executeCommand", json!({ - "referrer": { - "uri": "file:///a/file.ts", - }, - "uris": [ - { - "uri": "http://127.0.0.1:4545/x_deno_warning.js", - } + "command": "deno.cache", + "arguments": [ + ["http://127.0.0.1:4545/x_deno_warning.js"], + "file:///a/file.ts", ], }), ); @@ -8984,14 +8946,13 @@ export function B() { } })); client.write_request( - "deno/cache", + "workspace/executeCommand", json!({ - "referrer": { - "uri": "file:///a/file.tsx", - }, - "uris": [{ - "uri": "http://127.0.0.1:4545/jsx/jsx-runtime", - }], + "command": "deno.cache", + "arguments": [ + ["http://127.0.0.1:4545/jsx/jsx-runtime"], + "file:///a/file.tsx", + ], }), ); let res = client.write_request( @@ -9550,19 +9511,10 @@ fn lsp_node_modules_dir() { })); let cache = |client: &mut LspClient| { client.write_request( - "deno/cache", + "workspace/executeCommand", json!({ - "referrer": { - "uri": file_uri, - }, - "uris": [ - { - "uri": "npm:chalk", - }, - { - "uri": "npm:@types/node", - } - ] + "command": "deno.cache", + "arguments": [["npm:chalk", "npm:@types/node"], file_uri], }), ); }; @@ -9688,16 +9640,10 @@ fn lsp_vendor_dir() { })); let cache = |client: &mut LspClient| { client.write_request( - "deno/cache", + "workspace/executeCommand", json!({ - "referrer": { - "uri": local_file_uri, - }, - "uris": [ - { - "uri": "http://localhost:4545/subdir/mod1.ts", - } - ] + "command": "deno.cache", + "arguments": [["http://localhost:4545/subdir/mod1.ts"], local_file_uri], }), ); }; diff --git a/cli/tests/integration/npm_tests.rs b/cli/tests/integration/npm_tests.rs index 09330a80c..0fd0cdb4b 100644 --- a/cli/tests/integration/npm_tests.rs +++ b/cli/tests/integration/npm_tests.rs @@ -2155,8 +2155,11 @@ fn top_level_install_package_json_explicit_opt_in() { } })); client.write_request( - "deno/cache", - json!({ "referrer": { "uri": file_uri }, "uris": [] }), + "workspace/executeCommand", + json!({ + "command": "deno.cache", + "arguments": [[], file_uri], + }), ); assert!(node_modules_dir.join("@denotest").exists()); |