From 4240f757c0b219950f17797db325c2c4e14d732b Mon Sep 17 00:00:00 2001 From: Blaž Hrastnik Date: Thu, 11 Mar 2021 13:01:28 +0900 Subject: lsp: Fix compilation errors. --- helix-lsp/src/client.rs | 53 ++++++++++++------------------------------------- 1 file changed, 13 insertions(+), 40 deletions(-) (limited to 'helix-lsp') diff --git a/helix-lsp/src/client.rs b/helix-lsp/src/client.rs index 9c315272..1b67e215 100644 --- a/helix-lsp/src/client.rs +++ b/helix-lsp/src/client.rs @@ -583,7 +583,12 @@ impl Client { Ok(response.unwrap_or_default()) } - pub async fn goto_request( + async fn goto_request< + T: lsp::request::Request< + Params = lsp::GotoDefinitionParams, + Result = Option, + >, + >( &self, text_document: lsp::TextDocumentIdentifier, position: lsp::Position, @@ -628,7 +633,8 @@ impl Client { text_document: lsp::TextDocumentIdentifier, position: lsp::Position, ) -> anyhow::Result> { - self.goto_request(response).await + self.goto_request::(text_document, position) + .await } pub async fn goto_type_definition( @@ -636,24 +642,8 @@ impl Client { text_document: lsp::TextDocumentIdentifier, position: lsp::Position, ) -> anyhow::Result> { - let params = lsp::GotoDefinitionParams { - text_document_position_params: lsp::TextDocumentPositionParams { - text_document, - position, - }, - work_done_progress_params: lsp::WorkDoneProgressParams { - work_done_token: None, - }, - partial_result_params: lsp::PartialResultParams { - partial_result_token: None, - }, - }; - - let response = self - .request::(params) - .await?; - - self.goto_request(response).await + self.goto_request::(text_document, position) + .await } pub async fn goto_implementation( @@ -661,24 +651,8 @@ impl Client { text_document: lsp::TextDocumentIdentifier, position: lsp::Position, ) -> anyhow::Result> { - let params = lsp::GotoDefinitionParams { - text_document_position_params: lsp::TextDocumentPositionParams { - text_document, - position, - }, - work_done_progress_params: lsp::WorkDoneProgressParams { - work_done_token: None, - }, - partial_result_params: lsp::PartialResultParams { - partial_result_token: None, - }, - }; - - let response = self - .request::(params) - .await?; - - self.goto_request(response).await + self.goto_request::(text_document, position) + .await } pub async fn goto_reference( @@ -704,7 +678,6 @@ impl Client { let response = self.request::(params).await?; - self.goto_request(response.map(lsp::GotoDefinitionResponse::Array)) - .await + Ok(response.unwrap_or_default()) } } -- cgit v1.2.3-70-g09d2