0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-03-03 17:34:47 -05:00

chore(lsp): bump tower-lsp to 0.20.0 (#20693)

This commit is contained in:
Nayeem Rahman 2023-09-26 21:57:14 +01:00 committed by GitHub
parent dcb00bb9b8
commit cb154d6afa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 97 additions and 156 deletions

32
Cargo.lock generated
View file

@ -323,18 +323,6 @@ dependencies = [
"pin-project-lite", "pin-project-lite",
] ]
[[package]]
name = "auto_impl"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7862e21c893d65a1650125d157eaeec691439379a1cee17ee49031b79236ada4"
dependencies = [
"proc-macro-error",
"proc-macro2 1.0.67",
"quote 1.0.33",
"syn 1.0.109",
]
[[package]] [[package]]
name = "auto_impl" name = "auto_impl"
version = "1.1.0" version = "1.1.0"
@ -3263,9 +3251,9 @@ dependencies = [
[[package]] [[package]]
name = "lsp-types" name = "lsp-types"
version = "0.93.2" version = "0.94.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9be6e9c7e2d18f651974370d7aff703f9513e0df6e464fd795660edc77e6ca51" checksum = "c66bfd44a06ae10647fe3f8214762e9369fd4248df1350924b4ef9e770a85ea1"
dependencies = [ dependencies = [
"bitflags 1.3.2", "bitflags 1.3.2",
"serde", "serde",
@ -5521,7 +5509,7 @@ version = "0.21.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "90b996222612382d0d297d0315f5eedc5a830c37e62476c69774884633d31177" checksum = "90b996222612382d0d297d0315f5eedc5a830c37e62476c69774884633d31177"
dependencies = [ dependencies = [
"auto_impl 1.1.0", "auto_impl",
"petgraph", "petgraph",
"swc_common", "swc_common",
"swc_fast_graph", "swc_fast_graph",
@ -5940,17 +5928,16 @@ checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0"
[[package]] [[package]]
name = "tower-lsp" name = "tower-lsp"
version = "0.17.0" version = "0.20.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43e094780b4447366c59f79acfd65b1375ecaa84e61dddbde1421aa506334024" checksum = "d4ba052b54a6627628d9b3c34c176e7eda8359b7da9acd497b9f20998d118508"
dependencies = [ dependencies = [
"async-trait", "async-trait",
"auto_impl 0.5.0", "auto_impl",
"bytes", "bytes",
"dashmap 5.5.3", "dashmap 5.5.3",
"futures", "futures",
"httparse", "httparse",
"log",
"lsp-types", "lsp-types",
"memchr", "memchr",
"serde", "serde",
@ -5959,17 +5946,18 @@ dependencies = [
"tokio-util 0.7.9", "tokio-util 0.7.9",
"tower", "tower",
"tower-lsp-macros", "tower-lsp-macros",
"tracing",
] ]
[[package]] [[package]]
name = "tower-lsp-macros" name = "tower-lsp-macros"
version = "0.6.0" version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ebd99eec668d0a450c177acbc4d05e0d0d13b1f8d3db13cd706c52cbec4ac04" checksum = "84fd902d4e0b9a4b27f2f440108dc034e1758628a9b702f8ec61ad66355422fa"
dependencies = [ dependencies = [
"proc-macro2 1.0.67", "proc-macro2 1.0.67",
"quote 1.0.33", "quote 1.0.33",
"syn 1.0.109", "syn 2.0.37",
] ]
[[package]] [[package]]

View file

@ -105,7 +105,7 @@ indexmap1 = { package = "indexmap", version = "1", features = ["serde"] }
indexmap = { version = "2", features = ["serde"] } indexmap = { version = "2", features = ["serde"] }
libc = "0.2.126" libc = "0.2.126"
log = "=0.4.20" log = "=0.4.20"
lsp-types = "=0.93.2" # used by tower-lsp and "proposed" feature is unstable in patch releases lsp-types = "=0.94.1" # used by tower-lsp and "proposed" feature is unstable in patch releases
memmem = "0.1.1" memmem = "0.1.1"
monch = "=0.4.3" monch = "=0.4.3"
notify = "=5.0.0" notify = "=5.0.0"
@ -147,7 +147,7 @@ tokio = { version = "1.28.1", features = ["full"] }
tokio-metrics = { version = "0.3.0", features = ["rt"] } tokio-metrics = { version = "0.3.0", features = ["rt"] }
tokio-rustls = "0.24.0" tokio-rustls = "0.24.0"
tokio-util = "0.7.4" tokio-util = "0.7.4"
tower-lsp = { version = "=0.17.0", features = ["proposed"] } tower-lsp = { version = "=0.20.0", features = ["proposed"] }
url = { version = "2.3.1", features = ["serde", "expose_internals"] } url = { version = "2.3.1", features = ["serde", "expose_internals"] }
uuid = { version = "1.3.0", features = ["v4"] } uuid = { version = "1.3.0", features = ["v4"] }
zstd = "=0.12.4" zstd = "=0.12.4"

View file

@ -153,5 +153,8 @@ pub fn server_capabilities(
})), })),
inlay_hint_provider: Some(OneOf::Left(true)), inlay_hint_provider: Some(OneOf::Left(true)),
position_encoding: None, position_encoding: None,
// TODO(nayeemrmn): Support pull-based diagnostics.
diagnostic_provider: None,
inline_value_provider: None,
} }
} }

View file

@ -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( pub async fn virtual_text_document(
&self, &self,
params: Option<Value>, params: Option<Value>,
@ -3156,7 +3149,9 @@ impl tower_lsp::LanguageServer for LanguageServer {
// are interested in. // are interested in.
let options = DidChangeWatchedFilesRegistrationOptions { let options = DidChangeWatchedFilesRegistrationOptions {
watchers: vec![FileSystemWatcher { watchers: vec![FileSystemWatcher {
glob_pattern: "**/*.{json,jsonc,lock}".to_string(), glob_pattern: GlobPattern::String(
"**/*.{json,jsonc,lock}".to_string(),
),
kind: None, kind: None,
}], }],
}; };
@ -3417,6 +3412,13 @@ impl tower_lsp::LanguageServer for LanguageServer {
self.0.read().await.hover(params).await 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( async fn code_action(
&self, &self,
params: CodeActionParams, params: CodeActionParams,

View file

@ -13,9 +13,6 @@ pub const VIRTUAL_TEXT_DOCUMENT: &str = "deno/virtualTextDocument";
pub const LATEST_DIAGNOSTIC_BATCH_INDEX: &str = pub const LATEST_DIAGNOSTIC_BATCH_INDEX: &str =
"deno/internalLatestDiagnosticBatchIndex"; "deno/internalLatestDiagnosticBatchIndex";
// While lsp_types supports inlay hints currently, tower_lsp does not.
pub const INLAY_HINT: &str = "textDocument/inlayHint";
#[derive(Debug, Deserialize, Serialize)] #[derive(Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct CacheParams { pub struct CacheParams {

View file

@ -42,6 +42,8 @@ pub async fn start() -> Result<(), AnyError> {
let builder = LspService::build(|client| { let builder = LspService::build(|client| {
language_server::LanguageServer::new(client::Client::from_tower(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::CACHE_REQUEST, LanguageServer::cache_request)
.custom_method( .custom_method(
lsp_custom::PERFORMANCE_REQUEST, lsp_custom::PERFORMANCE_REQUEST,
@ -60,8 +62,7 @@ pub async fn start() -> Result<(), AnyError> {
.custom_method( .custom_method(
lsp_custom::VIRTUAL_TEXT_DOCUMENT, lsp_custom::VIRTUAL_TEXT_DOCUMENT,
LanguageServer::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() { let builder = if should_send_diagnostic_batch_index_notifications() {
builder.custom_method( builder.custom_method(

View file

@ -2993,6 +2993,7 @@ impl OutliningSpan {
Some(range.end.character) Some(range.end.character)
}, },
kind: self.get_folding_range_kind(&self.kind), kind: self.get_folding_range_kind(&self.kind),
collapsed_text: None,
} }
} }

View file

@ -235,10 +235,7 @@ fn lsp_import_map_remote() {
"workspace/executeCommand", "workspace/executeCommand",
json!({ json!({
"command": "deno.cache", "command": "deno.cache",
"arguments": [ "arguments": [[], temp_dir.uri().join("file.ts").unwrap()],
[],
temp_dir.uri().join("file.ts").unwrap(),
],
}), }),
); );
@ -1966,12 +1963,10 @@ fn lsp_hover_dependency() {
}), }),
); );
client.write_request( client.write_request(
"deno/cache", "workspace/executeCommand",
json!({ json!({
"referrer": { "command": "deno.cache",
"uri": "file:///a/file.ts", "arguments": [[], "file:///a/file.ts"],
},
"uris": [],
}), }),
); );
let res = client.write_request( let res = client.write_request(
@ -2199,15 +2194,12 @@ fn lsp_hover_typescript_types() {
}), }),
); );
client.write_request( client.write_request(
"deno/cache", "workspace/executeCommand",
json!({ json!({
"referrer": { "command": "deno.cache",
"uri": "file:///a/file.ts", "arguments": [
}, ["http://127.0.0.1:4545/xTypeScriptTypes.js"],
"uris": [ "file:///a/file.ts",
{
"uri": "http://127.0.0.1:4545/xTypeScriptTypes.js",
}
], ],
}), }),
); );
@ -5809,18 +5801,13 @@ fn lsp_npm_completions_auto_import_and_quick_fix_no_import_map() {
}), }),
); );
client.write_request( client.write_request(
"deno/cache", "workspace/executeCommand",
json!({ json!({
"referrer": { "command": "deno.cache",
"uri": "file:///a/file.ts", "arguments": [
}, ["npm:@denotest/types-exports-subpaths@1/client", "npm:chalk@5.0"],
"uris": [ "file:///a/file.ts",
{ ],
"uri": "npm:@denotest/types-exports-subpaths@1/client",
}, {
"uri": "npm:chalk@5.0",
}
]
}), }),
); );
@ -6123,22 +6110,18 @@ fn lsp_completions_auto_import_and_quick_fix_with_import_map() {
}), }),
); );
client.write_request( client.write_request(
"deno/cache", "workspace/executeCommand",
json!({ json!({
"referrer": { "command": "deno.cache",
"uri": "file:///a/file.ts", "arguments": [
}, [
"uris": [ "npm:@denotest/types-exports-subpaths@1/client",
{ "npm:chalk@^5.0",
"uri": "npm:@denotest/types-exports-subpaths@1/client", "npm:chalk@~5",
}, { "http://localhost:4545/subdir/print_hello.ts",
"uri": "npm:chalk@^5.0", ],
}, { "file:///a/file.ts",
"uri": "npm:chalk@~5", ],
}, {
"uri": "http://localhost:4545/subdir/print_hello.ts",
}
]
}), }),
); );
@ -6643,18 +6626,13 @@ fn lsp_completions_npm() {
}), }),
); );
client.write_request( client.write_request(
"deno/cache", "workspace/executeCommand",
json!({ json!({
"referrer": { "command": "deno.cache",
"uri": "file:///a/file.ts", "arguments": [
}, ["npm:@denotest/cjs-default-export", "npm:chalk"],
"uris": [ "file:///a/file.ts",
{ ],
"uri": "npm:@denotest/cjs-default-export",
}, {
"uri": "npm:chalk",
}
]
}), }),
); );
@ -7021,16 +6999,10 @@ fn lsp_completions_node_specifier() {
); );
client.write_request( client.write_request(
"deno/cache", "workspace/executeCommand",
json!({ json!({
"referrer": { "command": "deno.cache",
"uri": "file:///a/file.ts", "arguments": [["npm:@types/node"], "file:///a/file.ts"],
},
"uris": [
{
"uri": "npm:@types/node",
}
]
}), }),
); );
@ -7265,12 +7237,10 @@ fn lsp_cache_location() {
})); }));
assert_eq!(diagnostics.all().len(), 6); assert_eq!(diagnostics.all().len(), 6);
client.write_request( client.write_request(
"deno/cache", "workspace/executeCommand",
json!({ json!({
"referrer": { "command": "deno.cache",
"uri": "file:///a/file.ts", "arguments": [[], "file:///a/file.ts"],
},
"uris": [],
}), }),
); );
let res = client.write_request( let res = client.write_request(
@ -7361,12 +7331,10 @@ fn lsp_tls_cert() {
let diagnostics = diagnostics.all(); let diagnostics = diagnostics.all();
assert_eq!(diagnostics.len(), 6); assert_eq!(diagnostics.len(), 6);
client.write_request( client.write_request(
"deno/cache", "workspace/executeCommand",
json!({ json!({
"referrer": { "command": "deno.cache",
"uri": "file:///a/file.ts", "arguments": [[], "file:///a/file.ts"],
},
"uris": [],
}), }),
); );
let res = client.write_request( let res = client.write_request(
@ -7435,15 +7403,12 @@ fn lsp_diagnostics_warn_redirect() {
}), }),
); );
client.write_request( client.write_request(
"deno/cache", "workspace/executeCommand",
json!({ json!({
"referrer": { "command": "deno.cache",
"uri": "file:///a/file.ts", "arguments": [
}, ["http://127.0.0.1:4545/x_deno_warning.js"],
"uris": [ "file:///a/file.ts",
{
"uri": "http://127.0.0.1:4545/x_deno_warning.js",
}
], ],
}), }),
); );
@ -7514,15 +7479,12 @@ fn lsp_redirect_quick_fix() {
}), }),
); );
client.write_request( client.write_request(
"deno/cache", "workspace/executeCommand",
json!({ json!({
"referrer": { "command": "deno.cache",
"uri": "file:///a/file.ts", "arguments": [
}, ["http://127.0.0.1:4545/x_deno_warning.js"],
"uris": [ "file:///a/file.ts",
{
"uri": "http://127.0.0.1:4545/x_deno_warning.js",
}
], ],
}), }),
); );
@ -8984,14 +8946,13 @@ export function B() {
} }
})); }));
client.write_request( client.write_request(
"deno/cache", "workspace/executeCommand",
json!({ json!({
"referrer": { "command": "deno.cache",
"uri": "file:///a/file.tsx", "arguments": [
}, ["http://127.0.0.1:4545/jsx/jsx-runtime"],
"uris": [{ "file:///a/file.tsx",
"uri": "http://127.0.0.1:4545/jsx/jsx-runtime", ],
}],
}), }),
); );
let res = client.write_request( let res = client.write_request(
@ -9550,19 +9511,10 @@ fn lsp_node_modules_dir() {
})); }));
let cache = |client: &mut LspClient| { let cache = |client: &mut LspClient| {
client.write_request( client.write_request(
"deno/cache", "workspace/executeCommand",
json!({ json!({
"referrer": { "command": "deno.cache",
"uri": file_uri, "arguments": [["npm:chalk", "npm:@types/node"], file_uri],
},
"uris": [
{
"uri": "npm:chalk",
},
{
"uri": "npm:@types/node",
}
]
}), }),
); );
}; };
@ -9688,16 +9640,10 @@ fn lsp_vendor_dir() {
})); }));
let cache = |client: &mut LspClient| { let cache = |client: &mut LspClient| {
client.write_request( client.write_request(
"deno/cache", "workspace/executeCommand",
json!({ json!({
"referrer": { "command": "deno.cache",
"uri": local_file_uri, "arguments": [["http://localhost:4545/subdir/mod1.ts"], local_file_uri],
},
"uris": [
{
"uri": "http://localhost:4545/subdir/mod1.ts",
}
]
}), }),
); );
}; };

View file

@ -2155,8 +2155,11 @@ fn top_level_install_package_json_explicit_opt_in() {
} }
})); }));
client.write_request( client.write_request(
"deno/cache", "workspace/executeCommand",
json!({ "referrer": { "uri": file_uri }, "uris": [] }), json!({
"command": "deno.cache",
"arguments": [[], file_uri],
}),
); );
assert!(node_modules_dir.join("@denotest").exists()); assert!(node_modules_dir.join("@denotest").exists());