aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorkjeremy <[email protected]>2019-03-06 19:40:42 +0000
committerkjeremy <[email protected]>2019-03-06 19:40:42 +0000
commit064707c5a05e360d777b0b3ccbd8e30ad4acbda1 (patch)
tree6d7d8c3e6ccc95a7f9a7c4398516393ff2786623 /crates
parentaac421b1351d6c6dddb37a92a33d929b79ed1d70 (diff)
Use source map
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_hir/src/lib.rs2
-rw-r--r--crates/ra_ide_api/src/goto_definition.rs23
2 files changed, 10 insertions, 15 deletions
diff --git a/crates/ra_hir/src/lib.rs b/crates/ra_hir/src/lib.rs
index 74c718e72..a6e744ea7 100644
--- a/crates/ra_hir/src/lib.rs
+++ b/crates/ra_hir/src/lib.rs
@@ -60,7 +60,7 @@ pub use self::{
60 impl_block::{ImplBlock, ImplItem}, 60 impl_block::{ImplBlock, ImplItem},
61 docs::{Docs, Documentation}, 61 docs::{Docs, Documentation},
62 adt::AdtDef, 62 adt::AdtDef,
63 expr::{ExprScopes, ScopesWithSourceMap, ScopeEntryWithSyntax, Pat}, 63 expr::{ExprScopes, ScopesWithSourceMap, ScopeEntryWithSyntax},
64 resolve::{Resolver, Resolution}, 64 resolve::{Resolver, Resolution},
65}; 65};
66 66
diff --git a/crates/ra_ide_api/src/goto_definition.rs b/crates/ra_ide_api/src/goto_definition.rs
index 286ade0a4..dd5f9f31c 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::{Pat, Resolution}; 8use hir::Resolution;
9 9
10use crate::{FilePosition, NavigationTarget, db::RootDatabase, RangeInfo}; 10use crate::{FilePosition, NavigationTarget, db::RootDatabase, RangeInfo};
11 11
@@ -149,20 +149,15 @@ pub(crate) fn reference_definition(
149 name_ref.syntax().ancestors().find_map(ast::PathPat::cast) 149 name_ref.syntax().ancestors().find_map(ast::PathPat::cast)
150 { 150 {
151 let infer_result = function.infer(db); 151 let infer_result = function.infer(db);
152 let source_map = function.body_source_map(db);
152 153
153 if let Some(p) = path_pat.path().and_then(hir::Path::from_ast) { 154 let pat: &ast::Pat = path_pat.into();
154 if let Some(pat_id) = 155
155 function.body(db).pats().find_map(|(pat_id, pat)| match pat { 156 if let Some(res) = source_map
156 Pat::Path(ref path) if *path == p => Some(pat_id), 157 .node_pat(pat)
157 _ => None, 158 .and_then(|it| infer_result.assoc_resolutions_for_pat(it.into()))
158 }) 159 {
159 { 160 return Exact(NavigationTarget::from_impl_item(db, res));
160 if let Some(res) =
161 infer_result.assoc_resolutions_for_pat(pat_id.into())
162 {
163 return Exact(NavigationTarget::from_impl_item(db, res));
164 }
165 }
166 } 161 }
167 } 162 }
168 } 163 }