diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-10-14 13:22:54 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2019-10-14 13:22:54 +0100 |
commit | 1f4fbc0035a6a9ee1b599a3aa9f236989633a9f7 (patch) | |
tree | 40ee641fc90ecf384199ac537542deb71689d30d /crates/ra_cli | |
parent | bc7de5d47a56b9f2ab44f833130ba6d77aefe864 (diff) | |
parent | 1555a1aa0d5d45e4b317db272c07ad3e8470553d (diff) |
Merge #2007
2007: remove one more dependency on source roots r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_cli')
-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(); |