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/display/navigation_target.rs8
-rw-r--r--crates/ra_ide_api/src/goto_definition.rs8
2 files changed, 6 insertions, 10 deletions
diff --git a/crates/ra_ide_api/src/display/navigation_target.rs b/crates/ra_ide_api/src/display/navigation_target.rs
index 1e9cdaff4..823cdaaf3 100644
--- a/crates/ra_ide_api/src/display/navigation_target.rs
+++ b/crates/ra_ide_api/src/display/navigation_target.rs
@@ -163,10 +163,6 @@ impl NavigationTarget {
163 NavigationTarget::from_module(db, module) 163 NavigationTarget::from_module(db, module)
164 } 164 }
165 165
166 pub(crate) fn from_function(db: &RootDatabase, func: hir::Function) -> NavigationTarget {
167 NavigationTarget::from_def_source(db, func)
168 }
169
170 pub(crate) fn from_field(db: &RootDatabase, field: hir::StructField) -> NavigationTarget { 166 pub(crate) fn from_field(db: &RootDatabase, field: hir::StructField) -> NavigationTarget {
171 let src = field.source(db); 167 let src = field.source(db);
172 let file_id = src.file_id.original_file(db); 168 let file_id = src.file_id.original_file(db);
@@ -208,7 +204,7 @@ impl NavigationTarget {
208 ) -> Option<NavigationTarget> { 204 ) -> Option<NavigationTarget> {
209 let nav = match module_def { 205 let nav = match module_def {
210 hir::ModuleDef::Module(module) => NavigationTarget::from_module(db, module), 206 hir::ModuleDef::Module(module) => NavigationTarget::from_module(db, module),
211 hir::ModuleDef::Function(func) => NavigationTarget::from_function(db, func), 207 hir::ModuleDef::Function(func) => NavigationTarget::from_def_source(db, func),
212 hir::ModuleDef::Struct(it) => NavigationTarget::from_adt_def(db, it.into()), 208 hir::ModuleDef::Struct(it) => NavigationTarget::from_adt_def(db, it.into()),
213 hir::ModuleDef::Enum(it) => NavigationTarget::from_adt_def(db, it.into()), 209 hir::ModuleDef::Enum(it) => NavigationTarget::from_adt_def(db, it.into()),
214 hir::ModuleDef::Union(it) => NavigationTarget::from_adt_def(db, it.into()), 210 hir::ModuleDef::Union(it) => NavigationTarget::from_adt_def(db, it.into()),
@@ -241,7 +237,7 @@ impl NavigationTarget {
241 237
242 pub(crate) fn from_impl_item(db: &RootDatabase, impl_item: hir::ImplItem) -> NavigationTarget { 238 pub(crate) fn from_impl_item(db: &RootDatabase, impl_item: hir::ImplItem) -> NavigationTarget {
243 match impl_item { 239 match impl_item {
244 ImplItem::Method(it) => NavigationTarget::from_function(db, it), 240 ImplItem::Method(it) => NavigationTarget::from_def_source(db, it),
245 ImplItem::Const(it) => NavigationTarget::from_def_source(db, it), 241 ImplItem::Const(it) => NavigationTarget::from_def_source(db, it),
246 ImplItem::TypeAlias(it) => NavigationTarget::from_def_source(db, it), 242 ImplItem::TypeAlias(it) => NavigationTarget::from_def_source(db, it),
247 } 243 }
diff --git a/crates/ra_ide_api/src/goto_definition.rs b/crates/ra_ide_api/src/goto_definition.rs
index 325a5a4f3..63ba6cf9d 100644
--- a/crates/ra_ide_api/src/goto_definition.rs
+++ b/crates/ra_ide_api/src/goto_definition.rs
@@ -59,10 +59,10 @@ pub(crate) fn reference_definition(
59 let analyzer = hir::SourceAnalyzer::new(db, file_id, name_ref.syntax(), None); 59 let analyzer = hir::SourceAnalyzer::new(db, file_id, name_ref.syntax(), None);
60 60
61 match classify_name_ref(db, &analyzer, name_ref) { 61 match classify_name_ref(db, &analyzer, name_ref) {
62 Some(Method(func)) => return Exact(NavigationTarget::from_function(db, func)),
63 Some(Macro(mac)) => return Exact(NavigationTarget::from_macro_def(db, mac)), 62 Some(Macro(mac)) => return Exact(NavigationTarget::from_macro_def(db, mac)),
64 Some(FieldAccess(field)) => return Exact(NavigationTarget::from_field(db, field)), 63 Some(FieldAccess(field)) => return Exact(NavigationTarget::from_field(db, field)),
65 Some(AssocItem(assoc)) => return Exact(NavigationTarget::from_impl_item(db, assoc)), 64 Some(AssocItem(assoc)) => return Exact(NavigationTarget::from_impl_item(db, assoc)),
65 Some(Method(func)) => return Exact(NavigationTarget::from_def_source(db, func)),
66 Some(Def(def)) => match NavigationTarget::from_def(db, def) { 66 Some(Def(def)) => match NavigationTarget::from_def(db, def) {
67 Some(nav) => return Exact(nav), 67 Some(nav) => return Exact(nav),
68 None => return Approximate(vec![]), 68 None => return Approximate(vec![]),
@@ -253,12 +253,12 @@ mod tests {
253 //- /foo/lib.rs 253 //- /foo/lib.rs
254 #[macro_export] 254 #[macro_export]
255 macro_rules! foo { 255 macro_rules! foo {
256 () => { 256 () => {
257 {} 257 {}
258 }; 258 };
259 } 259 }
260 ", 260 ",
261 "foo MACRO_CALL FileId(2) [0; 79) [29; 32)", 261 "foo MACRO_CALL FileId(2) [0; 66) [29; 32)",
262 ); 262 );
263 } 263 }
264 264