aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_analysis/src/hover.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-01-05 17:00:03 +0000
committerAleksey Kladov <[email protected]>2019-01-05 17:00:03 +0000
commitee461a211195b093269ead477f01fcf63f20cf34 (patch)
tree9021f6b236ce24d19a7a419c9f8c9c08c9ff08f4 /crates/ra_analysis/src/hover.rs
parentda32463cbf8dc32229eb13844c71a40df2d3b77e (diff)
kill approximatelly_resolve_symbol
Diffstat (limited to 'crates/ra_analysis/src/hover.rs')
-rw-r--r--crates/ra_analysis/src/hover.rs17
1 files changed, 9 insertions, 8 deletions
diff --git a/crates/ra_analysis/src/hover.rs b/crates/ra_analysis/src/hover.rs
index 766fa0547..758de376e 100644
--- a/crates/ra_analysis/src/hover.rs
+++ b/crates/ra_analysis/src/hover.rs
@@ -1,4 +1,5 @@
1use ra_db::{Cancelable, SyntaxDatabase}; 1use ra_db::{Cancelable, SyntaxDatabase};
2use ra_editor::find_node_at_offset;
2use ra_syntax::{ 3use ra_syntax::{
3 AstNode, SyntaxNode, 4 AstNode, SyntaxNode,
4 ast::{self, NameOwner}, 5 ast::{self, NameOwner},
@@ -11,18 +12,18 @@ pub(crate) fn hover(
11 db: &RootDatabase, 12 db: &RootDatabase,
12 position: FilePosition, 13 position: FilePosition,
13) -> Cancelable<Option<RangeInfo<String>>> { 14) -> Cancelable<Option<RangeInfo<String>>> {
15 let file = db.source_file(position.file_id);
14 let mut res = Vec::new(); 16 let mut res = Vec::new();
15 let range = if let Some(rr) = db.approximately_resolve_symbol(position)? { 17 let range = if let Some(name_ref) =
16 for nav in rr.resolves_to { 18 find_node_at_offset::<ast::NameRef>(file.syntax(), position.offset)
19 {
20 let navs = crate::goto_defenition::reference_defenition(db, position.file_id, name_ref)?;
21 for nav in navs {
17 res.extend(doc_text_for(db, nav)?) 22 res.extend(doc_text_for(db, nav)?)
18 } 23 }
19 rr.reference_range 24 name_ref.syntax().range()
20 } else { 25 } else {
21 let file = db.source_file(position.file_id); 26 let expr: ast::Expr = ctry!(find_node_at_offset(file.syntax(), position.offset));
22 let expr: ast::Expr = ctry!(ra_editor::find_node_at_offset(
23 file.syntax(),
24 position.offset
25 ));
26 let frange = FileRange { 27 let frange = FileRange {
27 file_id: position.file_id, 28 file_id: position.file_id,
28 range: expr.syntax().range(), 29 range: expr.syntax().range(),