Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'lib/lsp-server/src/msg.rs')
-rw-r--r--lib/lsp-server/src/msg.rs12
1 files changed, 5 insertions, 7 deletions
diff --git a/lib/lsp-server/src/msg.rs b/lib/lsp-server/src/msg.rs
index 37eaf05346..264d8e5ce9 100644
--- a/lib/lsp-server/src/msg.rs
+++ b/lib/lsp-server/src/msg.rs
@@ -242,7 +242,7 @@ impl Response {
Response { id, response_result: Err(error) }
}
pub fn load<P: DeserializeOwned>(self) -> Result<P, ExtractError<Request>> {
- self.result.ok_or(ExtractError::NoResult).and_then(|x| {
+ self.response_result.ok().ok_or(ExtractError::NoResult).and_then(|x| {
serde_json::from_value(x)
.map_err(|error| ExtractError::JsonError { method: "".into(), error })
})
@@ -253,10 +253,10 @@ impl Request {
pub fn new<P: serde::Serialize>(id: RequestId, method: String, params: P) -> Request {
Request { id, method, params: serde_json::to_value(params).unwrap() }
}
- pub fn load<P: lsp_types::request::Request>(
+ pub fn load<P: lsp_types::Request>(
self,
) -> Result<(RequestId, P::Params), ExtractError<Request>> {
- if self.method != P::METHOD {
+ if self.method != P::METHOD.to_string() {
return Err(ExtractError::MethodMismatch(self));
}
match serde_json::from_value(self.params) {
@@ -289,10 +289,8 @@ impl Notification {
pub fn new(method: String, params: impl serde::Serialize) -> Notification {
Notification { method, params: serde_json::to_value(params).unwrap() }
}
- pub fn load<T: lsp_types::notification::Notification>(
- self,
- ) -> Result<T::Params, ExtractError<Notification>> {
- (self.method == T::METHOD).ok_or(ExtractError::NoResult).and_then(|()| {
+ pub fn load<T: lsp_types::Notification>(self) -> Result<T::Params, ExtractError<Notification>> {
+ (T::METHOD.as_str() == self.method).ok_or(ExtractError::NoResult).and_then(|()| {
serde_json::from_value(self.params)
.map_err(|e| ExtractError::JsonError { method: self.method, error: e })
})