aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_lsp_server
diff options
context:
space:
mode:
authorKirill Bulatov <[email protected]>2019-07-21 21:28:05 +0100
committerKirill Bulatov <[email protected]>2019-07-21 21:44:37 +0100
commit09c7c86696eb8289c9a8ab30bdbb824824c51eb1 (patch)
treed72cc0adb850d0d20774b3b2cffa148f686bc964 /crates/ra_lsp_server
parent24784c60df583d1807faa889a84312df1d2e3b22 (diff)
Resolve types on the server
Diffstat (limited to 'crates/ra_lsp_server')
-rw-r--r--crates/ra_lsp_server/src/main_loop/handlers.rs35
1 files changed, 10 insertions, 25 deletions
diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs
index 1077aafd8..e5d2ff832 100644
--- a/crates/ra_lsp_server/src/main_loop/handlers.rs
+++ b/crates/ra_lsp_server/src/main_loop/handlers.rs
@@ -9,8 +9,7 @@ use lsp_types::{
9 TextDocumentIdentifier, TextEdit, WorkspaceEdit, 9 TextDocumentIdentifier, TextEdit, WorkspaceEdit,
10}; 10};
11use ra_ide_api::{ 11use ra_ide_api::{
12 AssistId, Cancelable, FileId, FilePosition, FileRange, FoldKind, InlayKind, Query, 12 AssistId, Cancelable, FileId, FilePosition, FileRange, FoldKind, Query, RunnableKind, Severity,
13 RunnableKind, Severity,
14}; 13};
15use ra_prof::profile; 14use ra_prof::profile;
16use ra_syntax::{AstNode, SyntaxKind, TextRange, TextUnit}; 15use ra_syntax::{AstNode, SyntaxKind, TextRange, TextUnit};
@@ -750,29 +749,15 @@ pub fn handle_code_lens(
750 }), 749 }),
751 ); 750 );
752 751
753 lenses.extend( 752 lenses.extend(analysis.inlay_hints(file_id)?.into_iter().map(|inlay_hint| CodeLens {
754 analysis 753 range: inlay_hint.range.conv_with(&line_index),
755 .inlay_hints(file_id) 754 command: Some(Command {
756 .into_iter() 755 title: inlay_hint.inlay_type_string,
757 .filter(|hint| hint.inlay_kind == InlayKind::LetBinding) 756 command: String::new(),
758 .filter_map(|inlay_hint| { 757 arguments: None,
759 let resolved_type = analysis 758 }),
760 .type_of(FileRange { range: inlay_hint.range, file_id }) 759 data: None,
761 .ok() 760 }));
762 .and_then(std::convert::identity)
763 .filter(|resolved_type| "{unknown}" != resolved_type);
764 resolved_type.map(|resolved_type| (resolved_type, inlay_hint.range))
765 })
766 .map(|(resolved_type, range)| CodeLens {
767 range: range.conv_with(&line_index),
768 command: Some(Command {
769 title: resolved_type,
770 command: String::new(),
771 arguments: None,
772 }),
773 data: None,
774 }),
775 );
776 Ok(Some(lenses)) 761 Ok(Some(lenses))
777} 762}
778 763