diff options
author | Aleksey Kladov <[email protected]> | 2019-10-14 13:15:47 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-10-14 13:15:47 +0100 |
commit | 1555a1aa0d5d45e4b317db272c07ad3e8470553d (patch) | |
tree | f16b9bfdb058055b72e587ef4ac23b106e06ee7e /crates/ra_cli/src/analysis_stats.rs | |
parent | 77f2dd96a122e59a8d8df8afb53a741df9b1af76 (diff) |
remove one more dependency on source roots
Diffstat (limited to 'crates/ra_cli/src/analysis_stats.rs')
-rw-r--r-- | crates/ra_cli/src/analysis_stats.rs | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/crates/ra_cli/src/analysis_stats.rs b/crates/ra_cli/src/analysis_stats.rs index a8a110bd9..fe4f57dcd 100644 --- a/crates/ra_cli/src/analysis_stats.rs +++ b/crates/ra_cli/src/analysis_stats.rs | |||
@@ -22,16 +22,29 @@ pub fn run( | |||
22 | let mut num_crates = 0; | 22 | let mut num_crates = 0; |
23 | let mut visited_modules = HashSet::new(); | 23 | let mut visited_modules = HashSet::new(); |
24 | let mut visit_queue = Vec::new(); | 24 | let mut visit_queue = Vec::new(); |
25 | for (source_root_id, project_root) in roots { | 25 | |
26 | if project_root.is_member() { | 26 | let members = roots |
27 | for krate in Crate::source_root_crates(db, source_root_id) { | 27 | .into_iter() |
28 | num_crates += 1; | 28 | .filter_map( |
29 | let module = | 29 | |(source_root_id, project_root)| { |
30 | krate.root_module(db).expect("crate in source root without root module"); | 30 | if project_root.is_member() { |
31 | visit_queue.push(module); | 31 | Some(source_root_id) |
32 | } | 32 | } else { |
33 | None | ||
34 | } | ||
35 | }, | ||
36 | ) | ||
37 | .collect::<HashSet<_>>(); | ||
38 | |||
39 | for krate in Crate::all(db) { | ||
40 | let module = krate.root_module(db).expect("crate without root module"); | ||
41 | let file_id = module.definition_source(db).file_id; | ||
42 | if members.contains(&db.file_source_root(file_id.original_file(db))) { | ||
43 | num_crates += 1; | ||
44 | visit_queue.push(module); | ||
33 | } | 45 | } |
34 | } | 46 | } |
47 | |||
35 | println!("Crates in this dir: {}", num_crates); | 48 | println!("Crates in this dir: {}", num_crates); |
36 | let mut num_decls = 0; | 49 | let mut num_decls = 0; |
37 | let mut funcs = Vec::new(); | 50 | let mut funcs = Vec::new(); |