diff options
author | Aleksey Kladov <[email protected]> | 2019-01-30 19:18:17 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-01-30 19:36:22 +0000 |
commit | 95aa7e46fc69b5279a1af74dfa7008396a4455a5 (patch) | |
tree | e7439a2b29197ae3d202a66d50f737a7f45e40e5 /crates/ra_hir/src/query_definitions.rs | |
parent | b704ce803b99f0c69bbcd3d4ab531d2604de8594 (diff) |
move item_map_query
Diffstat (limited to 'crates/ra_hir/src/query_definitions.rs')
-rw-r--r-- | crates/ra_hir/src/query_definitions.rs | 33 |
1 files changed, 2 insertions, 31 deletions
diff --git a/crates/ra_hir/src/query_definitions.rs b/crates/ra_hir/src/query_definitions.rs index bf9ac0dfb..6724649e1 100644 --- a/crates/ra_hir/src/query_definitions.rs +++ b/crates/ra_hir/src/query_definitions.rs | |||
@@ -1,17 +1,11 @@ | |||
1 | use std::{ | 1 | use std::sync::Arc; |
2 | sync::Arc, | ||
3 | time::Instant, | ||
4 | }; | ||
5 | 2 | ||
6 | use rustc_hash::FxHashMap; | ||
7 | use ra_syntax::{SyntaxNode, TreeArc}; | 3 | use ra_syntax::{SyntaxNode, TreeArc}; |
8 | use ra_db::{CrateId}; | ||
9 | 4 | ||
10 | use crate::{ | 5 | use crate::{ |
11 | SourceFileItems, SourceItemId, HirFileId, | 6 | SourceFileItems, SourceItemId, HirFileId, |
12 | Function, FnScopes, Module, | 7 | Function, FnScopes, |
13 | db::HirDatabase, | 8 | db::HirDatabase, |
14 | nameres::{ItemMap, Resolver}, | ||
15 | }; | 9 | }; |
16 | 10 | ||
17 | pub(super) fn fn_scopes(db: &impl HirDatabase, func: Function) -> Arc<FnScopes> { | 11 | pub(super) fn fn_scopes(db: &impl HirDatabase, func: Function) -> Arc<FnScopes> { |
@@ -35,26 +29,3 @@ pub(super) fn file_item( | |||
35 | .to_node(&source_file) | 29 | .to_node(&source_file) |
36 | .to_owned() | 30 | .to_owned() |
37 | } | 31 | } |
38 | |||
39 | pub(super) fn item_map(db: &impl HirDatabase, crate_id: CrateId) -> Arc<ItemMap> { | ||
40 | let start = Instant::now(); | ||
41 | let module_tree = db.module_tree(crate_id); | ||
42 | let input = module_tree | ||
43 | .modules() | ||
44 | .map(|module_id| { | ||
45 | ( | ||
46 | module_id, | ||
47 | db.lower_module_module(Module { | ||
48 | krate: crate_id, | ||
49 | module_id, | ||
50 | }), | ||
51 | ) | ||
52 | }) | ||
53 | .collect::<FxHashMap<_, _>>(); | ||
54 | |||
55 | let resolver = Resolver::new(db, &input, crate_id); | ||
56 | let res = resolver.resolve(); | ||
57 | let elapsed = start.elapsed(); | ||
58 | log::info!("item_map: {:?}", elapsed); | ||
59 | Arc::new(res) | ||
60 | } | ||