diff options
Diffstat (limited to 'crates/ra_hir_def/src')
-rw-r--r-- | crates/ra_hir_def/src/db.rs | 4 | ||||
-rw-r--r-- | crates/ra_hir_def/src/find_path.rs | 7 |
2 files changed, 7 insertions, 4 deletions
diff --git a/crates/ra_hir_def/src/db.rs b/crates/ra_hir_def/src/db.rs index 2f71511ba..945a0025e 100644 --- a/crates/ra_hir_def/src/db.rs +++ b/crates/ra_hir_def/src/db.rs | |||
@@ -17,6 +17,7 @@ use crate::{ | |||
17 | item_scope::ItemInNs, | 17 | item_scope::ItemInNs, |
18 | lang_item::{LangItemTarget, LangItems}, | 18 | lang_item::{LangItemTarget, LangItems}, |
19 | nameres::{raw::RawItems, CrateDefMap}, | 19 | nameres::{raw::RawItems, CrateDefMap}, |
20 | path::ModPath, | ||
20 | visibility::Visibility, | 21 | visibility::Visibility, |
21 | AttrDefId, ConstId, ConstLoc, DefWithBodyId, EnumId, EnumLoc, FunctionId, FunctionLoc, | 22 | AttrDefId, ConstId, ConstLoc, DefWithBodyId, EnumId, EnumLoc, FunctionId, FunctionLoc, |
22 | GenericDefId, ImplId, ImplLoc, ModuleId, StaticId, StaticLoc, StructId, StructLoc, TraitId, | 23 | GenericDefId, ImplId, ImplLoc, ModuleId, StaticId, StaticLoc, StructId, StructLoc, TraitId, |
@@ -118,6 +119,9 @@ pub trait DefDatabase: InternDatabase + AstDatabase + Upcast<dyn AstDatabase> { | |||
118 | item: ItemInNs, | 119 | item: ItemInNs, |
119 | krate: CrateId, | 120 | krate: CrateId, |
120 | ) -> Arc<[(ModuleId, Name, Visibility)]>; | 121 | ) -> Arc<[(ModuleId, Name, Visibility)]>; |
122 | |||
123 | #[salsa::invoke(find_path::find_path_inner_query)] | ||
124 | fn find_path_inner(&self, item: ItemInNs, from: ModuleId, max_len: usize) -> Option<ModPath>; | ||
121 | } | 125 | } |
122 | 126 | ||
123 | fn crate_def_map_wait(db: &impl DefDatabase, krate: CrateId) -> Arc<CrateDefMap> { | 127 | fn crate_def_map_wait(db: &impl DefDatabase, krate: CrateId) -> Arc<CrateDefMap> { |
diff --git a/crates/ra_hir_def/src/find_path.rs b/crates/ra_hir_def/src/find_path.rs index 68d3cde08..4db798473 100644 --- a/crates/ra_hir_def/src/find_path.rs +++ b/crates/ra_hir_def/src/find_path.rs | |||
@@ -20,7 +20,7 @@ use crate::{ | |||
20 | /// *from where* you're referring to the item, hence the `from` parameter. | 20 | /// *from where* you're referring to the item, hence the `from` parameter. |
21 | pub fn find_path(db: &dyn DefDatabase, item: ItemInNs, from: ModuleId) -> Option<ModPath> { | 21 | pub fn find_path(db: &dyn DefDatabase, item: ItemInNs, from: ModuleId) -> Option<ModPath> { |
22 | let _p = profile("find_path"); | 22 | let _p = profile("find_path"); |
23 | find_path_inner(db, item, from, MAX_PATH_LEN) | 23 | db.find_path_inner(item, from, MAX_PATH_LEN) |
24 | } | 24 | } |
25 | 25 | ||
26 | const MAX_PATH_LEN: usize = 15; | 26 | const MAX_PATH_LEN: usize = 15; |
@@ -49,7 +49,7 @@ impl ModPath { | |||
49 | } | 49 | } |
50 | } | 50 | } |
51 | 51 | ||
52 | fn find_path_inner( | 52 | pub(crate) fn find_path_inner_query( |
53 | db: &dyn DefDatabase, | 53 | db: &dyn DefDatabase, |
54 | item: ItemInNs, | 54 | item: ItemInNs, |
55 | from: ModuleId, | 55 | from: ModuleId, |
@@ -140,8 +140,7 @@ fn find_path_inner( | |||
140 | let mut best_path = None; | 140 | let mut best_path = None; |
141 | let mut best_path_len = max_len; | 141 | let mut best_path_len = max_len; |
142 | for (module_id, name) in importable_locations { | 142 | for (module_id, name) in importable_locations { |
143 | let mut path = match find_path_inner( | 143 | let mut path = match db.find_path_inner( |
144 | db, | ||
145 | ItemInNs::Types(ModuleDefId::ModuleId(module_id)), | 144 | ItemInNs::Types(ModuleDefId::ModuleId(module_id)), |
146 | from, | 145 | from, |
147 | best_path_len - 1, | 146 | best_path_len - 1, |