aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_cli
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_cli')
-rw-r--r--crates/ra_cli/Cargo.toml2
-rw-r--r--crates/ra_cli/src/analysis_bench.rs2
-rw-r--r--crates/ra_cli/src/analysis_stats.rs33
3 files changed, 25 insertions, 12 deletions
diff --git a/crates/ra_cli/Cargo.toml b/crates/ra_cli/Cargo.toml
index 67e727a88..fcd102e8b 100644
--- a/crates/ra_cli/Cargo.toml
+++ b/crates/ra_cli/Cargo.toml
@@ -8,7 +8,7 @@ publish = false
8[dependencies] 8[dependencies]
9pico-args = "0.3.0" 9pico-args = "0.3.0"
10flexi_logger = "0.14.0" 10flexi_logger = "0.14.0"
11indicatif = "0.11.0" 11indicatif = "0.12.0"
12 12
13ra_syntax = { path = "../ra_syntax" } 13ra_syntax = { path = "../ra_syntax" }
14ra_ide_api = { path = "../ra_ide_api" } 14ra_ide_api = { path = "../ra_ide_api" }
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..cda5cafb8 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();
@@ -130,7 +143,7 @@ pub fn run(
130 ); 143 );
131 bar.println(format!( 144 bar.println(format!(
132 "{} {}:{}-{}:{}: Expected {}, got {}", 145 "{} {}:{}-{}:{}: Expected {}, got {}",
133 path.display(), 146 path,
134 start.line + 1, 147 start.line + 1,
135 start.col_utf16, 148 start.col_utf16,
136 end.line + 1, 149 end.line + 1,