aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide_api')
-rw-r--r--crates/ra_ide_api/src/goto_definition.rs21
-rw-r--r--crates/ra_ide_api/src/hover.rs2
2 files changed, 17 insertions, 6 deletions
diff --git a/crates/ra_ide_api/src/goto_definition.rs b/crates/ra_ide_api/src/goto_definition.rs
index e4febe8cc..3b66483cb 100644
--- a/crates/ra_ide_api/src/goto_definition.rs
+++ b/crates/ra_ide_api/src/goto_definition.rs
@@ -5,7 +5,7 @@ use ra_syntax::{
5 SyntaxNode, 5 SyntaxNode,
6}; 6};
7use test_utils::tested_by; 7use test_utils::tested_by;
8use hir::Resolution; 8use hir::{ImplItem, Resolution};
9 9
10use crate::{FilePosition, NavigationTarget, db::RootDatabase, RangeInfo}; 10use crate::{FilePosition, NavigationTarget, db::RootDatabase, RangeInfo};
11 11
@@ -131,14 +131,25 @@ pub(crate) fn reference_definition(
131 name_ref.syntax().ancestors().find_map(ast::PathExpr::cast) 131 name_ref.syntax().ancestors().find_map(ast::PathExpr::cast)
132 { 132 {
133 let infer_result = function.infer(db); 133 let infer_result = function.infer(db);
134 let syntax_mapping = function.body_syntax_mapping(db); 134 let source_map = function.body_source_map(db);
135 let expr = ast::Expr::cast(path_expr.syntax()).unwrap(); 135 let expr = ast::Expr::cast(path_expr.syntax()).unwrap();
136 136
137 if let Some(func) = syntax_mapping 137 if let Some(res) = source_map
138 .node_expr(expr) 138 .node_expr(expr)
139 .and_then(|it| infer_result.assoc_fn_resolutions(it)) 139 .and_then(|it| infer_result.assoc_resolutions(it.into()))
140 { 140 {
141 return Exact(NavigationTarget::from_function(db, func)); 141 match res {
142 ImplItem::Method(f) => {
143 return Exact(NavigationTarget::from_function(db, f));
144 }
145 ImplItem::Const(c) => {
146 let (file, node) = c.source(db);
147 let file = file.original_file(db);
148 let node = &*node;
149 return Exact(NavigationTarget::from_named(file, node));
150 }
151 _ => {}
152 }
142 } 153 }
143 } 154 }
144 } 155 }
diff --git a/crates/ra_ide_api/src/hover.rs b/crates/ra_ide_api/src/hover.rs
index 0f13777d7..bcd052c8b 100644
--- a/crates/ra_ide_api/src/hover.rs
+++ b/crates/ra_ide_api/src/hover.rs
@@ -531,7 +531,7 @@ mod tests {
531 ", 531 ",
532 ); 532 );
533 let hover = analysis.hover(position).unwrap().unwrap(); 533 let hover = analysis.hover(position).unwrap().unwrap();
534 assert_eq!(hover.info.first(), Some("```rust\nfn new() -> Thing\n```")); 534 assert_eq!(trim_markup_opt(hover.info.first()), Some("fn new() -> Thing"));
535 assert_eq!(hover.info.is_exact(), true); 535 assert_eq!(hover.info.is_exact(), true);
536 } 536 }
537} 537}