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