aboutsummaryrefslogtreecommitdiff
path: root/crates/gen_lsp_server
diff options
context:
space:
mode:
Diffstat (limited to 'crates/gen_lsp_server')
-rw-r--r--crates/gen_lsp_server/Cargo.toml3
-rw-r--r--crates/gen_lsp_server/src/msg.rs12
2 files changed, 10 insertions, 5 deletions
diff --git a/crates/gen_lsp_server/Cargo.toml b/crates/gen_lsp_server/Cargo.toml
index 6c91e38aa..9776a82e3 100644
--- a/crates/gen_lsp_server/Cargo.toml
+++ b/crates/gen_lsp_server/Cargo.toml
@@ -12,6 +12,5 @@ languageserver-types = "0.53.0"
12log = "0.4.3" 12log = "0.4.3"
13failure = "0.1.2" 13failure = "0.1.2"
14serde_json = "1.0.24" 14serde_json = "1.0.24"
15serde = "1.0.71" 15serde = { version = "1.0.71", features = ["derive"] }
16serde_derive = "1.0.71"
17crossbeam-channel = "0.2.4" 16crossbeam-channel = "0.2.4"
diff --git a/crates/gen_lsp_server/src/msg.rs b/crates/gen_lsp_server/src/msg.rs
index 22d273d55..f68cbc541 100644
--- a/crates/gen_lsp_server/src/msg.rs
+++ b/crates/gen_lsp_server/src/msg.rs
@@ -1,13 +1,13 @@
1use std::io::{BufRead, Write}; 1use std::io::{BufRead, Write};
2 2
3use languageserver_types::{notification::Notification, request::Request}; 3use languageserver_types::{notification::Notification, request::Request};
4use serde_derive::{Deserialize, Serialize}; 4use serde::{Deserialize, Serialize};
5use serde_json::{from_str, from_value, to_string, to_value, Value}; 5use serde_json::{from_str, from_value, to_string, to_value, Value};
6use failure::{bail, format_err}; 6use failure::{bail, format_err};
7 7
8use crate::Result; 8use crate::Result;
9 9
10#[derive(Debug, Serialize, Deserialize, Clone)] 10#[derive(Serialize, Deserialize, Debug, Clone)]
11#[serde(untagged)] 11#[serde(untagged)]
12pub enum RawMessage { 12pub enum RawMessage {
13 Request(RawRequest), 13 Request(RawRequest),
@@ -152,12 +152,18 @@ impl RawNotification {
152 params: to_value(params).unwrap(), 152 params: to_value(params).unwrap(),
153 } 153 }
154 } 154 }
155 pub fn is<N>(&self) -> bool
156 where
157 N: Notification,
158 {
159 self.method == N::METHOD
160 }
155 pub fn cast<N>(self) -> ::std::result::Result<N::Params, RawNotification> 161 pub fn cast<N>(self) -> ::std::result::Result<N::Params, RawNotification>
156 where 162 where
157 N: Notification, 163 N: Notification,
158 N::Params: serde::de::DeserializeOwned, 164 N::Params: serde::de::DeserializeOwned,
159 { 165 {
160 if self.method != N::METHOD { 166 if !self.is::<N>() {
161 return Err(self); 167 return Err(self);
162 } 168 }
163 Ok(from_value(self.params).unwrap()) 169 Ok(from_value(self.params).unwrap())