diff options
Diffstat (limited to 'crates/ra_ide_api/src/hover.rs')
-rw-r--r-- | crates/ra_ide_api/src/hover.rs | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/crates/ra_ide_api/src/hover.rs b/crates/ra_ide_api/src/hover.rs index b66774cdf..2968b807c 100644 --- a/crates/ra_ide_api/src/hover.rs +++ b/crates/ra_ide_api/src/hover.rs | |||
@@ -16,9 +16,16 @@ pub(crate) fn hover( | |||
16 | 16 | ||
17 | let mut range = None; | 17 | let mut range = None; |
18 | if let Some(name_ref) = find_node_at_offset::<ast::NameRef>(file.syntax(), position.offset) { | 18 | if let Some(name_ref) = find_node_at_offset::<ast::NameRef>(file.syntax(), position.offset) { |
19 | let navs = crate::goto_definition::reference_definition(db, position.file_id, name_ref)?; | 19 | use crate::goto_definition::{ReferenceResult::*, reference_definition}; |
20 | for nav in navs { | 20 | let ref_result = reference_definition(db, position.file_id, name_ref)?; |
21 | res.extend(doc_text_for(db, nav)?) | 21 | match ref_result { |
22 | Exact(nav) => res.extend(doc_text_for(db, nav)?), | ||
23 | Approximate(navs) => { | ||
24 | res.push("Failed to exactly resolve the symbol. This is probably because rust_analyzer does not yet support glob imports or traits. \nThese methods were found instead:".to_string()); | ||
25 | for nav in navs { | ||
26 | res.extend(doc_text_for(db, nav)?) | ||
27 | } | ||
28 | } | ||
22 | } | 29 | } |
23 | if !res.is_empty() { | 30 | if !res.is_empty() { |
24 | range = Some(name_ref.syntax().range()) | 31 | range = Some(name_ref.syntax().range()) |
@@ -34,7 +41,7 @@ pub(crate) fn hover( | |||
34 | file_id: position.file_id, | 41 | file_id: position.file_id, |
35 | range: node.range(), | 42 | range: node.range(), |
36 | }; | 43 | }; |
37 | res.extend(type_of(db, frange)?); | 44 | res.extend(type_of(db, frange)?.map(Into::into)); |
38 | range = Some(node.range()); | 45 | range = Some(node.range()); |
39 | }; | 46 | }; |
40 | 47 | ||