mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 13:25:09 +00:00
⬆️ rust-analyzer
This commit is contained in:
parent
3a57388d13
commit
4f55ebbd4f
122 changed files with 2885 additions and 1093 deletions
|
@ -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.85"
|
||||
serde = { version = "1.0.144", features = ["derive"] }
|
||||
crossbeam-channel = "0.5.6"
|
||||
|
||||
[dev-dependencies]
|
||||
lsp-types = "0.93.0"
|
||||
lsp-types = "0.93.1"
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -35,6 +35,7 @@ impl<I> Incoming<I> {
|
|||
pub fn register(&mut self, id: RequestId, data: I) {
|
||||
self.pending.insert(id, data);
|
||||
}
|
||||
|
||||
pub fn cancel(&mut self, id: RequestId) -> Option<Response> {
|
||||
let _data = self.complete(id.clone())?;
|
||||
let error = ResponseError {
|
||||
|
@ -44,9 +45,14 @@ impl<I> Incoming<I> {
|
|||
};
|
||||
Some(Response { id, result: None, error: Some(error) })
|
||||
}
|
||||
|
||||
pub fn complete(&mut self, id: RequestId) -> Option<I> {
|
||||
self.pending.remove(&id)
|
||||
}
|
||||
|
||||
pub fn is_completed(&self, id: &RequestId) -> bool {
|
||||
!self.pending.contains_key(id)
|
||||
}
|
||||
}
|
||||
|
||||
impl<O> Outgoing<O> {
|
||||
|
@ -56,6 +62,7 @@ impl<O> Outgoing<O> {
|
|||
self.next_id += 1;
|
||||
Request::new(id, method, params)
|
||||
}
|
||||
|
||||
pub fn complete(&mut self, id: RequestId) -> Option<O> {
|
||||
self.pending.remove(&id)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue