|
|
|
@ -583,10 +583,26 @@ impl Client {
|
|
|
|
|
Ok(response.unwrap_or_default())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub async fn goto_generic(
|
|
|
|
|
pub async fn goto_request<T: lsp::request::Request>(
|
|
|
|
|
&self,
|
|
|
|
|
response: Option<lsp::GotoDefinitionResponse>,
|
|
|
|
|
text_document: lsp::TextDocumentIdentifier,
|
|
|
|
|
position: lsp::Position,
|
|
|
|
|
) -> anyhow::Result<Vec<lsp::Location>> {
|
|
|
|
|
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::<T>(params).await?;
|
|
|
|
|
|
|
|
|
|
let items = match response {
|
|
|
|
|
Some(lsp::GotoDefinitionResponse::Scalar(location)) => vec![location],
|
|
|
|
|
Some(lsp::GotoDefinitionResponse::Array(location_vec)) => location_vec,
|
|
|
|
@ -612,22 +628,7 @@ impl Client {
|
|
|
|
|
text_document: lsp::TextDocumentIdentifier,
|
|
|
|
|
position: lsp::Position,
|
|
|
|
|
) -> anyhow::Result<Vec<lsp::Location>> {
|
|
|
|
|
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::<lsp::request::GotoDefinition>(params).await?;
|
|
|
|
|
|
|
|
|
|
self.goto_generic(response).await
|
|
|
|
|
self.goto_request(response).await
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub async fn goto_type_definition(
|
|
|
|
@ -652,7 +653,7 @@ impl Client {
|
|
|
|
|
.request::<lsp::request::GotoTypeDefinition>(params)
|
|
|
|
|
.await?;
|
|
|
|
|
|
|
|
|
|
self.goto_generic(response).await
|
|
|
|
|
self.goto_request(response).await
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub async fn goto_implementation(
|
|
|
|
@ -677,7 +678,7 @@ impl Client {
|
|
|
|
|
.request::<lsp::request::GotoImplementation>(params)
|
|
|
|
|
.await?;
|
|
|
|
|
|
|
|
|
|
self.goto_generic(response).await
|
|
|
|
|
self.goto_request(response).await
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub async fn goto_reference(
|
|
|
|
@ -703,7 +704,7 @@ impl Client {
|
|
|
|
|
|
|
|
|
|
let response = self.request::<lsp::request::References>(params).await?;
|
|
|
|
|
|
|
|
|
|
self.goto_generic(response.map(lsp::GotoDefinitionResponse::Array))
|
|
|
|
|
self.goto_request(response.map(lsp::GotoDefinitionResponse::Array))
|
|
|
|
|
.await
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|