diff options
Diffstat (limited to 'crates/ra_ide_api/src/goto_definition.rs')
-rw-r--r-- | crates/ra_ide_api/src/goto_definition.rs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/crates/ra_ide_api/src/goto_definition.rs b/crates/ra_ide_api/src/goto_definition.rs index 6c8387f6c..5b7fb3c15 100644 --- a/crates/ra_ide_api/src/goto_definition.rs +++ b/crates/ra_ide_api/src/goto_definition.rs | |||
@@ -1,5 +1,6 @@ | |||
1 | //! FIXME: write short doc here | 1 | //! FIXME: write short doc here |
2 | 2 | ||
3 | use hir::Source; | ||
3 | use ra_db::{FileId, SourceDatabase}; | 4 | use ra_db::{FileId, SourceDatabase}; |
4 | use ra_syntax::{ | 5 | use ra_syntax::{ |
5 | algo::find_node_at_offset, | 6 | algo::find_node_at_offset, |
@@ -21,7 +22,8 @@ pub(crate) fn goto_definition( | |||
21 | let parse = db.parse(position.file_id); | 22 | let parse = db.parse(position.file_id); |
22 | let syntax = parse.tree().syntax().clone(); | 23 | let syntax = parse.tree().syntax().clone(); |
23 | if let Some(name_ref) = find_node_at_offset::<ast::NameRef>(&syntax, position.offset) { | 24 | if let Some(name_ref) = find_node_at_offset::<ast::NameRef>(&syntax, position.offset) { |
24 | let navs = reference_definition(db, position.file_id, &name_ref).to_vec(); | 25 | let navs = |
26 | reference_definition(db, Source::new(position.file_id.into(), &name_ref)).to_vec(); | ||
25 | return Some(RangeInfo::new(name_ref.syntax().text_range(), navs.to_vec())); | 27 | return Some(RangeInfo::new(name_ref.syntax().text_range(), navs.to_vec())); |
26 | } | 28 | } |
27 | if let Some(name) = find_node_at_offset::<ast::Name>(&syntax, position.offset) { | 29 | if let Some(name) = find_node_at_offset::<ast::Name>(&syntax, position.offset) { |
@@ -49,12 +51,11 @@ impl ReferenceResult { | |||
49 | 51 | ||
50 | pub(crate) fn reference_definition( | 52 | pub(crate) fn reference_definition( |
51 | db: &RootDatabase, | 53 | db: &RootDatabase, |
52 | file_id: FileId, | 54 | name_ref: Source<&ast::NameRef>, |
53 | name_ref: &ast::NameRef, | ||
54 | ) -> ReferenceResult { | 55 | ) -> ReferenceResult { |
55 | use self::ReferenceResult::*; | 56 | use self::ReferenceResult::*; |
56 | 57 | ||
57 | let name_kind = classify_name_ref(db, file_id, &name_ref).map(|d| d.kind); | 58 | let name_kind = classify_name_ref(db, name_ref).map(|d| d.kind); |
58 | match name_kind { | 59 | match name_kind { |
59 | Some(Macro(mac)) => return Exact(mac.to_nav(db)), | 60 | Some(Macro(mac)) => return Exact(mac.to_nav(db)), |
60 | Some(Field(field)) => return Exact(field.to_nav(db)), | 61 | Some(Field(field)) => return Exact(field.to_nav(db)), |
@@ -76,7 +77,7 @@ pub(crate) fn reference_definition( | |||
76 | }; | 77 | }; |
77 | 78 | ||
78 | // Fallback index based approach: | 79 | // Fallback index based approach: |
79 | let navs = crate::symbol_index::index_resolve(db, name_ref) | 80 | let navs = crate::symbol_index::index_resolve(db, name_ref.ast) |
80 | .into_iter() | 81 | .into_iter() |
81 | .map(|s| s.to_nav(db)) | 82 | .map(|s| s.to_nav(db)) |
82 | .collect(); | 83 | .collect(); |