diff options
Diffstat (limited to 'crates/ra_cli')
-rw-r--r-- | crates/ra_cli/src/analysis_stats.rs | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/crates/ra_cli/src/analysis_stats.rs b/crates/ra_cli/src/analysis_stats.rs index c19976bd2..d76c37d84 100644 --- a/crates/ra_cli/src/analysis_stats.rs +++ b/crates/ra_cli/src/analysis_stats.rs | |||
@@ -1,7 +1,6 @@ | |||
1 | use std::{collections::HashSet, time::Instant, fmt::Write}; | 1 | use std::{collections::HashSet, time::Instant, fmt::Write}; |
2 | 2 | ||
3 | use ra_db::SourceDatabase; | 3 | use ra_db::SourceDatabase; |
4 | use ra_batch::BatchDatabase; | ||
5 | use ra_hir::{Crate, ModuleDef, Ty, ImplItem, HasSource}; | 4 | use ra_hir::{Crate, ModuleDef, Ty, ImplItem, HasSource}; |
6 | use ra_syntax::AstNode; | 5 | use ra_syntax::AstNode; |
7 | 6 | ||
@@ -9,16 +8,17 @@ use crate::Result; | |||
9 | 8 | ||
10 | pub fn run(verbose: bool, path: &str, only: Option<&str>) -> Result<()> { | 9 | pub fn run(verbose: bool, path: &str, only: Option<&str>) -> Result<()> { |
11 | let db_load_time = Instant::now(); | 10 | let db_load_time = Instant::now(); |
12 | let (db, roots) = BatchDatabase::load_cargo(path)?; | 11 | let (host, roots) = ra_batch::load_cargo(path.as_ref())?; |
12 | let db = host.raw_database(); | ||
13 | println!("Database loaded, {} roots, {:?}", roots.len(), db_load_time.elapsed()); | 13 | println!("Database loaded, {} roots, {:?}", roots.len(), db_load_time.elapsed()); |
14 | let analysis_time = Instant::now(); | 14 | let analysis_time = Instant::now(); |
15 | let mut num_crates = 0; | 15 | let mut num_crates = 0; |
16 | let mut visited_modules = HashSet::new(); | 16 | let mut visited_modules = HashSet::new(); |
17 | let mut visit_queue = Vec::new(); | 17 | let mut visit_queue = Vec::new(); |
18 | for root in roots { | 18 | for root in roots { |
19 | for krate in Crate::source_root_crates(&db, root) { | 19 | for krate in Crate::source_root_crates(db, root) { |
20 | num_crates += 1; | 20 | num_crates += 1; |
21 | let module = krate.root_module(&db).expect("crate in source root without root module"); | 21 | let module = krate.root_module(db).expect("crate in source root without root module"); |
22 | visit_queue.push(module); | 22 | visit_queue.push(module); |
23 | } | 23 | } |
24 | } | 24 | } |
@@ -27,17 +27,17 @@ pub fn run(verbose: bool, path: &str, only: Option<&str>) -> Result<()> { | |||
27 | let mut funcs = Vec::new(); | 27 | let mut funcs = Vec::new(); |
28 | while let Some(module) = visit_queue.pop() { | 28 | while let Some(module) = visit_queue.pop() { |
29 | if visited_modules.insert(module) { | 29 | if visited_modules.insert(module) { |
30 | visit_queue.extend(module.children(&db)); | 30 | visit_queue.extend(module.children(db)); |
31 | 31 | ||
32 | for decl in module.declarations(&db) { | 32 | for decl in module.declarations(db) { |
33 | num_decls += 1; | 33 | num_decls += 1; |
34 | if let ModuleDef::Function(f) = decl { | 34 | if let ModuleDef::Function(f) = decl { |
35 | funcs.push(f); | 35 | funcs.push(f); |
36 | } | 36 | } |
37 | } | 37 | } |
38 | 38 | ||
39 | for impl_block in module.impl_blocks(&db) { | 39 | for impl_block in module.impl_blocks(db) { |
40 | for item in impl_block.items(&db) { | 40 | for item in impl_block.items(db) { |
41 | num_decls += 1; | 41 | num_decls += 1; |
42 | if let ImplItem::Method(f) = item { | 42 | if let ImplItem::Method(f) = item { |
43 | funcs.push(f); | 43 | funcs.push(f); |
@@ -61,11 +61,11 @@ pub fn run(verbose: bool, path: &str, only: Option<&str>) -> Result<()> { | |||
61 | let mut num_exprs_unknown = 0; | 61 | let mut num_exprs_unknown = 0; |
62 | let mut num_exprs_partially_unknown = 0; | 62 | let mut num_exprs_partially_unknown = 0; |
63 | for f in funcs { | 63 | for f in funcs { |
64 | let name = f.name(&db); | 64 | let name = f.name(db); |
65 | let mut msg = format!("processing: {}", name); | 65 | let mut msg = format!("processing: {}", name); |
66 | if verbose { | 66 | if verbose { |
67 | let src = f.source(&db); | 67 | let src = f.source(db); |
68 | let original_file = src.file_id.original_file(&db); | 68 | let original_file = src.file_id.original_file(db); |
69 | let path = db.file_relative_path(original_file); | 69 | let path = db.file_relative_path(original_file); |
70 | let syntax_range = src.ast.syntax().range(); | 70 | let syntax_range = src.ast.syntax().range(); |
71 | write!(msg, " ({:?} {})", path, syntax_range).unwrap(); | 71 | write!(msg, " ({:?} {})", path, syntax_range).unwrap(); |
@@ -76,8 +76,8 @@ pub fn run(verbose: bool, path: &str, only: Option<&str>) -> Result<()> { | |||
76 | continue; | 76 | continue; |
77 | } | 77 | } |
78 | } | 78 | } |
79 | let body = f.body(&db); | 79 | let body = f.body(db); |
80 | let inference_result = f.infer(&db); | 80 | let inference_result = f.infer(db); |
81 | for (expr_id, _) in body.exprs() { | 81 | for (expr_id, _) in body.exprs() { |
82 | let ty = &inference_result[expr_id]; | 82 | let ty = &inference_result[expr_id]; |
83 | num_exprs += 1; | 83 | num_exprs += 1; |