diff options
Diffstat (limited to 'crates/ra_hir/src/query_definitions.rs')
-rw-r--r-- | crates/ra_hir/src/query_definitions.rs | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/crates/ra_hir/src/query_definitions.rs b/crates/ra_hir/src/query_definitions.rs index 074153862..cf8c7e435 100644 --- a/crates/ra_hir/src/query_definitions.rs +++ b/crates/ra_hir/src/query_definitions.rs | |||
@@ -7,17 +7,17 @@ use rustc_hash::FxHashMap; | |||
7 | use ra_syntax::{ | 7 | use ra_syntax::{ |
8 | AstNode, SyntaxNode, TreeArc, | 8 | AstNode, SyntaxNode, TreeArc, |
9 | }; | 9 | }; |
10 | use ra_db::SourceRootId; | 10 | use ra_db::{CrateId}; |
11 | 11 | ||
12 | use crate::{ | 12 | use crate::{ |
13 | SourceFileItems, SourceItemId, DefId, HirFileId, | 13 | SourceFileItems, SourceItemId, HirFileId, |
14 | FnScopes, | 14 | Function, FnScopes, Module, |
15 | db::HirDatabase, | 15 | db::HirDatabase, |
16 | nameres::{ItemMap, Resolver}, | 16 | nameres::{ItemMap, Resolver}, |
17 | }; | 17 | }; |
18 | 18 | ||
19 | pub(super) fn fn_scopes(db: &impl HirDatabase, def_id: DefId) -> Arc<FnScopes> { | 19 | pub(super) fn fn_scopes(db: &impl HirDatabase, func: Function) -> Arc<FnScopes> { |
20 | let body = db.body_hir(def_id); | 20 | let body = db.body_hir(func); |
21 | let res = FnScopes::new(body); | 21 | let res = FnScopes::new(body); |
22 | Arc::new(res) | 22 | Arc::new(res) |
23 | } | 23 | } |
@@ -41,15 +41,23 @@ pub(super) fn file_item( | |||
41 | } | 41 | } |
42 | } | 42 | } |
43 | 43 | ||
44 | pub(super) fn item_map(db: &impl HirDatabase, source_root: SourceRootId) -> Arc<ItemMap> { | 44 | pub(super) fn item_map(db: &impl HirDatabase, crate_id: CrateId) -> Arc<ItemMap> { |
45 | let start = Instant::now(); | 45 | let start = Instant::now(); |
46 | let module_tree = db.module_tree(source_root); | 46 | let module_tree = db.module_tree(crate_id); |
47 | let input = module_tree | 47 | let input = module_tree |
48 | .modules() | 48 | .modules() |
49 | .map(|id| (id, db.lower_module_module(source_root, id))) | 49 | .map(|module_id| { |
50 | ( | ||
51 | module_id, | ||
52 | db.lower_module_module(Module { | ||
53 | krate: crate_id, | ||
54 | module_id, | ||
55 | }), | ||
56 | ) | ||
57 | }) | ||
50 | .collect::<FxHashMap<_, _>>(); | 58 | .collect::<FxHashMap<_, _>>(); |
51 | 59 | ||
52 | let resolver = Resolver::new(db, &input, source_root, module_tree); | 60 | let resolver = Resolver::new(db, &input, crate_id); |
53 | let res = resolver.resolve(); | 61 | let res = resolver.resolve(); |
54 | let elapsed = start.elapsed(); | 62 | let elapsed = start.elapsed(); |
55 | log::info!("item_map: {:?}", elapsed); | 63 | log::info!("item_map: {:?}", elapsed); |