From 2560a9e8076d0b83f606af3029ea1a0c7bc48514 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 5 Jan 2019 16:40:50 +0300 Subject: wip --- crates/ra_analysis/src/imp.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'crates/ra_analysis/src') diff --git a/crates/ra_analysis/src/imp.rs b/crates/ra_analysis/src/imp.rs index eae73c2c4..10248013c 100644 --- a/crates/ra_analysis/src/imp.rs +++ b/crates/ra_analysis/src/imp.rs @@ -269,6 +269,32 @@ impl db::RootDatabase { Ok(result) } + pub(crate) fn hover(&self, position: FilePosition) -> Cancelable> { + let mut res = Vec::new(); + let range = if let Some(rr) = self.approximately_resolve_symbol(position)? { + for nav in rr.resolves_to { + res.extend(self.doc_text_for(nav)?) + } + rr.reference_range + } else { + let file = self.source_file(position.file_id); + let expr: ast::Expr = ctry!(ra_editor::find_node_at_offset( + file.syntax(), + position.offset + )); + let frange = FileRange { + file_id: position.file_id, + range: expr.syntax().range(), + }; + res.extend(self.type_of(frange)?); + expr.syntax().range() + }; + if res.is_empty() { + return Ok(None); + } + Ok(Some((range, res.join("\n\n---\n")))) + } + pub(crate) fn diagnostics(&self, file_id: FileId) -> Cancelable> { let syntax = self.source_file(file_id); -- cgit v1.2.3