diff options
Diffstat (limited to 'crates/ra_lsp_server/src/main_loop/handlers.rs')
-rw-r--r-- | crates/ra_lsp_server/src/main_loop/handlers.rs | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index f18a1305d..92e92f836 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs | |||
@@ -203,11 +203,12 @@ pub fn handle_goto_definition( | |||
203 | params: req::TextDocumentPositionParams, | 203 | params: req::TextDocumentPositionParams, |
204 | ) -> Result<Option<req::GotoDefinitionResponse>> { | 204 | ) -> Result<Option<req::GotoDefinitionResponse>> { |
205 | let position = params.try_conv_with(&world)?; | 205 | let position = params.try_conv_with(&world)?; |
206 | let mut res = Vec::new(); | 206 | let rr = match world.analysis().approximately_resolve_symbol(position)? { |
207 | for (file_id, symbol) in match world.analysis().approximately_resolve_symbol(position)? { | ||
208 | None => return Ok(None), | 207 | None => return Ok(None), |
209 | Some(it) => it.1, | 208 | Some(it) => it, |
210 | } { | 209 | }; |
210 | let mut res = Vec::new(); | ||
211 | for (file_id, symbol) in rr.resolves_to { | ||
211 | let line_index = world.analysis().file_line_index(file_id); | 212 | let line_index = world.analysis().file_line_index(file_id); |
212 | let location = to_location(file_id, symbol.node_range, &world, &line_index)?; | 213 | let location = to_location(file_id, symbol.node_range, &world, &line_index)?; |
213 | res.push(location) | 214 | res.push(location) |
@@ -510,17 +511,17 @@ pub fn handle_hover( | |||
510 | // TODO: Cut down on number of allocations | 511 | // TODO: Cut down on number of allocations |
511 | let position = params.try_conv_with(&world)?; | 512 | let position = params.try_conv_with(&world)?; |
512 | let line_index = world.analysis().file_line_index(position.file_id); | 513 | let line_index = world.analysis().file_line_index(position.file_id); |
513 | let (range, resolved) = match world.analysis().approximately_resolve_symbol(position)? { | 514 | let rr = match world.analysis().approximately_resolve_symbol(position)? { |
514 | None => return Ok(None), | 515 | None => return Ok(None), |
515 | Some(it) => it, | 516 | Some(it) => it, |
516 | }; | 517 | }; |
517 | let mut result = Vec::new(); | 518 | let mut result = Vec::new(); |
518 | for (file_id, symbol) in resolved { | 519 | for (file_id, symbol) in rr.resolves_to { |
519 | if let Some(docs) = world.analysis().doc_text_for(file_id, symbol)? { | 520 | if let Some(docs) = world.analysis().doc_text_for(file_id, symbol)? { |
520 | result.push(docs); | 521 | result.push(docs); |
521 | } | 522 | } |
522 | } | 523 | } |
523 | let range = range.conv_with(&line_index); | 524 | let range = rr.reference_range.conv_with(&line_index); |
524 | if result.len() > 0 { | 525 | if result.len() > 0 { |
525 | return Ok(Some(Hover { | 526 | return Ok(Some(Hover { |
526 | contents: HoverContents::Scalar(MarkedString::String(result.join("\n\n---\n"))), | 527 | contents: HoverContents::Scalar(MarkedString::String(result.join("\n\n---\n"))), |