diff options
Diffstat (limited to 'crates/ra_cli/src/analysis_stats.rs')
-rw-r--r-- | crates/ra_cli/src/analysis_stats.rs | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/crates/ra_cli/src/analysis_stats.rs b/crates/ra_cli/src/analysis_stats.rs index 1fad5b233..8f4ce42da 100644 --- a/crates/ra_cli/src/analysis_stats.rs +++ b/crates/ra_cli/src/analysis_stats.rs | |||
@@ -4,9 +4,14 @@ use ra_db::SourceDatabase; | |||
4 | use ra_hir::{Crate, HasBodySource, HasSource, HirDisplay, ImplItem, ModuleDef, Ty, TypeWalk}; | 4 | use ra_hir::{Crate, HasBodySource, HasSource, HirDisplay, ImplItem, ModuleDef, Ty, TypeWalk}; |
5 | use ra_syntax::AstNode; | 5 | use ra_syntax::AstNode; |
6 | 6 | ||
7 | use crate::Result; | 7 | use crate::{Result, Verbosity}; |
8 | 8 | ||
9 | pub fn run(verbose: bool, memory_usage: bool, path: &Path, only: Option<&str>) -> Result<()> { | 9 | pub fn run( |
10 | verbosity: Verbosity, | ||
11 | memory_usage: bool, | ||
12 | path: &Path, | ||
13 | only: Option<&str>, | ||
14 | ) -> Result<()> { | ||
10 | let db_load_time = Instant::now(); | 15 | let db_load_time = Instant::now(); |
11 | let (mut host, roots) = ra_batch::load_cargo(path)?; | 16 | let (mut host, roots) = ra_batch::load_cargo(path)?; |
12 | let db = host.raw_database(); | 17 | let db = host.raw_database(); |
@@ -55,10 +60,14 @@ pub fn run(verbose: bool, memory_usage: bool, path: &Path, only: Option<&str>) - | |||
55 | println!("Item Collection: {:?}, {}", analysis_time.elapsed(), ra_prof::memory_usage()); | 60 | println!("Item Collection: {:?}, {}", analysis_time.elapsed(), ra_prof::memory_usage()); |
56 | 61 | ||
57 | let inference_time = Instant::now(); | 62 | let inference_time = Instant::now(); |
58 | let bar = indicatif::ProgressBar::with_draw_target( | 63 | let bar = match verbosity { |
59 | funcs.len() as u64, | 64 | Verbosity::Verbose | Verbosity::Normal => indicatif::ProgressBar::with_draw_target( |
60 | indicatif::ProgressDrawTarget::stderr_nohz(), | 65 | funcs.len() as u64, |
61 | ); | 66 | indicatif::ProgressDrawTarget::stderr_nohz(), |
67 | ), | ||
68 | Verbosity::Quiet => indicatif::ProgressBar::hidden(), | ||
69 | }; | ||
70 | |||
62 | bar.set_style( | 71 | bar.set_style( |
63 | indicatif::ProgressStyle::default_bar().template("{wide_bar} {pos}/{len}\n{msg}"), | 72 | indicatif::ProgressStyle::default_bar().template("{wide_bar} {pos}/{len}\n{msg}"), |
64 | ); | 73 | ); |
@@ -70,7 +79,7 @@ pub fn run(verbose: bool, memory_usage: bool, path: &Path, only: Option<&str>) - | |||
70 | for f in funcs { | 79 | for f in funcs { |
71 | let name = f.name(db); | 80 | let name = f.name(db); |
72 | let mut msg = format!("processing: {}", name); | 81 | let mut msg = format!("processing: {}", name); |
73 | if verbose { | 82 | if verbosity.is_verbose() { |
74 | let src = f.source(db); | 83 | let src = f.source(db); |
75 | let original_file = src.file_id.original_file(db); | 84 | let original_file = src.file_id.original_file(db); |
76 | let path = db.file_relative_path(original_file); | 85 | let path = db.file_relative_path(original_file); |
@@ -103,7 +112,7 @@ pub fn run(verbose: bool, memory_usage: bool, path: &Path, only: Option<&str>) - | |||
103 | } | 112 | } |
104 | if let Some(mismatch) = inference_result.type_mismatch_for_expr(expr_id) { | 113 | if let Some(mismatch) = inference_result.type_mismatch_for_expr(expr_id) { |
105 | num_type_mismatches += 1; | 114 | num_type_mismatches += 1; |
106 | if verbose { | 115 | if verbosity.is_verbose() { |
107 | let src = f.expr_source(db, expr_id); | 116 | let src = f.expr_source(db, expr_id); |
108 | if let Some(src) = src { | 117 | if let Some(src) = src { |
109 | // FIXME: it might be nice to have a function (on Analysis?) that goes from Source<T> -> (LineCol, LineCol) directly | 118 | // FIXME: it might be nice to have a function (on Analysis?) that goes from Source<T> -> (LineCol, LineCol) directly |