aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_cli
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-05-14 07:58:41 +0100
committerAleksey Kladov <[email protected]>2019-05-14 07:58:41 +0100
commitd4b1e958c56132ce3743d847d2d75a308607e92f (patch)
tree2bc40e5152ccc4e0946d1ad31278d4be9ba8c9d3 /crates/ra_cli
parentc417c77b681f10cc7585507bd874e9fd2cea63b8 (diff)
show current function in analysis-stats progress bar
Diffstat (limited to 'crates/ra_cli')
-rw-r--r--crates/ra_cli/src/analysis_stats.rs9
-rw-r--r--crates/ra_cli/src/main.rs2
2 files changed, 8 insertions, 3 deletions
diff --git a/crates/ra_cli/src/analysis_stats.rs b/crates/ra_cli/src/analysis_stats.rs
index e6b2b30c6..c95d452b3 100644
--- a/crates/ra_cli/src/analysis_stats.rs
+++ b/crates/ra_cli/src/analysis_stats.rs
@@ -1,4 +1,4 @@
1use std::{collections::HashSet, time::Instant}; 1use std::{collections::HashSet, time::Instant, fmt::Write};
2 2
3use ra_db::SourceDatabase; 3use ra_db::SourceDatabase;
4use ra_batch::BatchDatabase; 4use ra_batch::BatchDatabase;
@@ -52,19 +52,24 @@ pub fn run(verbose: bool, path: &str, only: Option<&str>) -> Result<()> {
52 println!("Total declarations: {}", num_decls); 52 println!("Total declarations: {}", num_decls);
53 println!("Total functions: {}", funcs.len()); 53 println!("Total functions: {}", funcs.len());
54 let bar = indicatif::ProgressBar::new(funcs.len() as u64); 54 let bar = indicatif::ProgressBar::new(funcs.len() as u64);
55 bar.set_style(
56 indicatif::ProgressStyle::default_bar().template("{wide_bar} {pos}/{len}\n{msg}"),
57 );
55 bar.tick(); 58 bar.tick();
56 let mut num_exprs = 0; 59 let mut num_exprs = 0;
57 let mut num_exprs_unknown = 0; 60 let mut num_exprs_unknown = 0;
58 let mut num_exprs_partially_unknown = 0; 61 let mut num_exprs_partially_unknown = 0;
59 for f in funcs { 62 for f in funcs {
60 let name = f.name(&db); 63 let name = f.name(&db);
64 let mut msg = format!("processing: {}", name);
61 if verbose { 65 if verbose {
62 let (file_id, source) = f.source(&db); 66 let (file_id, source) = f.source(&db);
63 let original_file = file_id.original_file(&db); 67 let original_file = file_id.original_file(&db);
64 let path = db.file_relative_path(original_file); 68 let path = db.file_relative_path(original_file);
65 let syntax_range = source.syntax().range(); 69 let syntax_range = source.syntax().range();
66 println!("{} ({:?} {})", name, path, syntax_range); 70 write!(msg, " ({:?} {})", path, syntax_range).unwrap();
67 } 71 }
72 bar.set_message(&msg);
68 if let Some(only_name) = only { 73 if let Some(only_name) = only {
69 if name.to_string() != only_name { 74 if name.to_string() != only_name {
70 continue; 75 continue;
diff --git a/crates/ra_cli/src/main.rs b/crates/ra_cli/src/main.rs
index 038f5f3fe..f11d0e6bd 100644
--- a/crates/ra_cli/src/main.rs
+++ b/crates/ra_cli/src/main.rs
@@ -18,7 +18,7 @@ fn main() -> Result<()> {
18 .subcommand(SubCommand::with_name("symbols")) 18 .subcommand(SubCommand::with_name("symbols"))
19 .subcommand( 19 .subcommand(
20 SubCommand::with_name("analysis-stats") 20 SubCommand::with_name("analysis-stats")
21 .arg(Arg::with_name("verbose").short("v")) 21 .arg(Arg::with_name("verbose").short("v").long("verbose"))
22 .arg(Arg::with_name("only").short("o").takes_value(true)) 22 .arg(Arg::with_name("only").short("o").takes_value(true))
23 .arg(Arg::with_name("path")), 23 .arg(Arg::with_name("path")),
24 ) 24 )