From a53c5de1fd970fed989eb6435ba6a8c67362c63b Mon Sep 17 00:00:00 2001 From: DJMcNab <36049421+DJMcNab@users.noreply.github.com> Date: Sun, 13 Jan 2019 10:31:37 +0000 Subject: Add an explanatory message when we use the Query fallback --- crates/ra_ide_api/src/hover.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'crates/ra_ide_api/src/hover.rs') 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( let mut range = None; if let Some(name_ref) = find_node_at_offset::(file.syntax(), position.offset) { - let navs = crate::goto_definition::reference_definition(db, position.file_id, name_ref)?; - for nav in navs { - res.extend(doc_text_for(db, nav)?) + use crate::goto_definition::{ReferenceResult::*, reference_definition}; + let ref_result = reference_definition(db, position.file_id, name_ref)?; + match ref_result { + Exact(nav) => res.extend(doc_text_for(db, nav)?), + Approximate(navs) => { + 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()); + for nav in navs { + res.extend(doc_text_for(db, nav)?) + } + } } if !res.is_empty() { range = Some(name_ref.syntax().range()) @@ -34,7 +41,7 @@ pub(crate) fn hover( file_id: position.file_id, range: node.range(), }; - res.extend(type_of(db, frange)?); + res.extend(type_of(db, frange)?.map(Into::into)); range = Some(node.range()); }; -- cgit v1.2.3