diff options
Diffstat (limited to 'crates/ra_lsp_server/src')
-rw-r--r-- | crates/ra_lsp_server/src/main_loop.rs (renamed from crates/ra_lsp_server/src/main_loop/mod.rs) | 0 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/main_loop/handlers.rs | 36 |
2 files changed, 22 insertions, 14 deletions
diff --git a/crates/ra_lsp_server/src/main_loop/mod.rs b/crates/ra_lsp_server/src/main_loop.rs index 0e1878906..0e1878906 100644 --- a/crates/ra_lsp_server/src/main_loop/mod.rs +++ b/crates/ra_lsp_server/src/main_loop.rs | |||
diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index af21254e4..92e92f836 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs | |||
@@ -203,8 +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 rr = match world.analysis().approximately_resolve_symbol(position)? { | ||
207 | None => return Ok(None), | ||
208 | Some(it) => it, | ||
209 | }; | ||
206 | let mut res = Vec::new(); | 210 | let mut res = Vec::new(); |
207 | for (file_id, symbol) in world.analysis().approximately_resolve_symbol(position)? { | 211 | for (file_id, symbol) in rr.resolves_to { |
208 | let line_index = world.analysis().file_line_index(file_id); | 212 | let line_index = world.analysis().file_line_index(file_id); |
209 | 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)?; |
210 | res.push(location) | 214 | res.push(location) |
@@ -504,26 +508,30 @@ pub fn handle_hover( | |||
504 | world: ServerWorld, | 508 | world: ServerWorld, |
505 | params: req::TextDocumentPositionParams, | 509 | params: req::TextDocumentPositionParams, |
506 | ) -> Result<Option<Hover>> { | 510 | ) -> Result<Option<Hover>> { |
511 | // TODO: Cut down on number of allocations | ||
507 | let position = params.try_conv_with(&world)?; | 512 | let position = params.try_conv_with(&world)?; |
508 | let line_index = world.analysis().file_line_index(position.file_id); | 513 | let line_index = world.analysis().file_line_index(position.file_id); |
509 | 514 | let rr = match world.analysis().approximately_resolve_symbol(position)? { | |
510 | for (file_id, symbol) in world.analysis().approximately_resolve_symbol(position)? { | 515 | None => return Ok(None), |
511 | let range = symbol.node_range.conv_with(&line_index); | 516 | Some(it) => it, |
512 | let comment = world.analysis.doc_comment_for(file_id, symbol)?; | 517 | }; |
513 | 518 | let mut result = Vec::new(); | |
514 | if comment.is_some() { | 519 | for (file_id, symbol) in rr.resolves_to { |
515 | let contents = HoverContents::Scalar(MarkedString::String(comment.unwrap())); | 520 | if let Some(docs) = world.analysis().doc_text_for(file_id, symbol)? { |
516 | 521 | result.push(docs); | |
517 | return Ok(Some(Hover { | ||
518 | contents, | ||
519 | range: Some(range), | ||
520 | })); | ||
521 | } | 522 | } |
522 | } | 523 | } |
523 | 524 | let range = rr.reference_range.conv_with(&line_index); | |
525 | if result.len() > 0 { | ||
526 | return Ok(Some(Hover { | ||
527 | contents: HoverContents::Scalar(MarkedString::String(result.join("\n\n---\n"))), | ||
528 | range: Some(range), | ||
529 | })); | ||
530 | } | ||
524 | Ok(None) | 531 | Ok(None) |
525 | } | 532 | } |
526 | 533 | ||
534 | /// Test doc comment | ||
527 | pub fn handle_prepare_rename( | 535 | pub fn handle_prepare_rename( |
528 | world: ServerWorld, | 536 | world: ServerWorld, |
529 | params: req::TextDocumentPositionParams, | 537 | params: req::TextDocumentPositionParams, |