From 20431706a863f92cb37dc512fef6e48d192aaf2c Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:11:38 +0200 Subject: Merging upstream version 1.66.0+dfsg1. Signed-off-by: Daniel Baumann --- src/tools/rust-analyzer/lib/lsp-server/Cargo.toml | 10 +++++----- src/tools/rust-analyzer/lib/lsp-server/src/msg.rs | 10 +++++++++- src/tools/rust-analyzer/lib/lsp-server/src/req_queue.rs | 7 +++++++ 3 files changed, 21 insertions(+), 6 deletions(-) (limited to 'src/tools/rust-analyzer/lib/lsp-server') diff --git a/src/tools/rust-analyzer/lib/lsp-server/Cargo.toml b/src/tools/rust-analyzer/lib/lsp-server/Cargo.toml index 204d120d0..5922bbfdb 100644 --- a/src/tools/rust-analyzer/lib/lsp-server/Cargo.toml +++ b/src/tools/rust-analyzer/lib/lsp-server/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "lsp-server" -version = "0.6.0" +version = "0.7.0" description = "Generic LSP server scaffold." license = "MIT OR Apache-2.0" repository = "https://github.com/rust-lang/rust-analyzer/tree/master/lib/lsp-server" @@ -8,9 +8,9 @@ edition = "2021" [dependencies] log = "0.4.17" -serde_json = "1.0.81" -serde = { version = "1.0.137", features = ["derive"] } -crossbeam-channel = "0.5.5" +serde_json = "1.0.86" +serde = { version = "1.0.144", features = ["derive"] } +crossbeam-channel = "0.5.6" [dev-dependencies] -lsp-types = "0.93.0" +lsp-types = "0.93.1" diff --git a/src/tools/rust-analyzer/lib/lsp-server/src/msg.rs b/src/tools/rust-analyzer/lib/lsp-server/src/msg.rs index 97e5bd35c..b241561f9 100644 --- a/src/tools/rust-analyzer/lib/lsp-server/src/msg.rs +++ b/src/tools/rust-analyzer/lib/lsp-server/src/msg.rs @@ -98,7 +98,7 @@ pub struct ResponseError { } #[derive(Clone, Copy, Debug)] -#[allow(unused)] +#[non_exhaustive] pub enum ErrorCode { // Defined by JSON RPC: ParseError = -32700, @@ -135,6 +135,14 @@ pub enum ErrorCode { /// /// @since 3.17.0 ServerCancelled = -32802, + + /// A request failed but it was syntactically correct, e.g the + /// method name was known and the parameters were valid. The error + /// message should contain human readable information about why + /// the request failed. + /// + /// @since 3.17.0 + RequestFailed = -32803, } #[derive(Debug, Serialize, Deserialize, Clone)] diff --git a/src/tools/rust-analyzer/lib/lsp-server/src/req_queue.rs b/src/tools/rust-analyzer/lib/lsp-server/src/req_queue.rs index 1f3d44715..e5f19be20 100644 --- a/src/tools/rust-analyzer/lib/lsp-server/src/req_queue.rs +++ b/src/tools/rust-analyzer/lib/lsp-server/src/req_queue.rs @@ -35,6 +35,7 @@ impl Incoming { pub fn register(&mut self, id: RequestId, data: I) { self.pending.insert(id, data); } + pub fn cancel(&mut self, id: RequestId) -> Option { let _data = self.complete(id.clone())?; let error = ResponseError { @@ -44,9 +45,14 @@ impl Incoming { }; Some(Response { id, result: None, error: Some(error) }) } + pub fn complete(&mut self, id: RequestId) -> Option { self.pending.remove(&id) } + + pub fn is_completed(&self, id: &RequestId) -> bool { + !self.pending.contains_key(id) + } } impl Outgoing { @@ -56,6 +62,7 @@ impl Outgoing { self.next_id += 1; Request::new(id, method, params) } + pub fn complete(&mut self, id: RequestId) -> Option { self.pending.remove(&id) } -- cgit v1.2.3