aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_cli/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_cli/src')
-rw-r--r--crates/ra_cli/src/analysis_bench.rs2
-rw-r--r--crates/ra_cli/src/analysis_stats.rs31
2 files changed, 23 insertions, 10 deletions
diff --git a/crates/ra_cli/src/analysis_bench.rs b/crates/ra_cli/src/analysis_bench.rs
index 727f1e62b..8bbe5d9e8 100644
--- a/crates/ra_cli/src/analysis_bench.rs
+++ b/crates/ra_cli/src/analysis_bench.rs
@@ -8,7 +8,7 @@ use std::{
8 8
9use ra_db::{ 9use ra_db::{
10 salsa::{Database, Durability}, 10 salsa::{Database, Durability},
11 FileId, SourceDatabase, 11 FileId, SourceDatabaseExt,
12}; 12};
13use ra_ide_api::{Analysis, AnalysisChange, AnalysisHost, FilePosition, LineCol}; 13use ra_ide_api::{Analysis, AnalysisChange, AnalysisHost, FilePosition, LineCol};
14 14
diff --git a/crates/ra_cli/src/analysis_stats.rs b/crates/ra_cli/src/analysis_stats.rs
index a8a110bd9..35c867dce 100644
--- a/crates/ra_cli/src/analysis_stats.rs
+++ b/crates/ra_cli/src/analysis_stats.rs
@@ -2,7 +2,7 @@
2 2
3use std::{collections::HashSet, fmt::Write, path::Path, time::Instant}; 3use std::{collections::HashSet, fmt::Write, path::Path, time::Instant};
4 4
5use ra_db::SourceDatabase; 5use ra_db::SourceDatabaseExt;
6use ra_hir::{AssocItem, Crate, HasBodySource, HasSource, HirDisplay, ModuleDef, Ty, TypeWalk}; 6use ra_hir::{AssocItem, Crate, HasBodySource, HasSource, HirDisplay, ModuleDef, Ty, TypeWalk};
7use ra_syntax::AstNode; 7use ra_syntax::AstNode;
8 8
@@ -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();