From d4b1e958c56132ce3743d847d2d75a308607e92f Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 14 May 2019 09:58:41 +0300 Subject: [PATCH] show current function in analysis-stats progress bar --- crates/ra_cli/src/analysis_stats.rs | 9 +++++++-- crates/ra_cli/src/main.rs | 2 +- 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 e6b2b30c678..c95d452b35c 100644 --- a/crates/ra_cli/src/analysis_stats.rs +++ b/crates/ra_cli/src/analysis_stats.rs @@ -1,4 +1,4 @@ -use std::{collections::HashSet, time::Instant}; +use std::{collections::HashSet, time::Instant, fmt::Write}; use ra_db::SourceDatabase; use ra_batch::BatchDatabase; @@ -52,19 +52,24 @@ pub fn run(verbose: bool, path: &str, only: Option<&str>) -> Result<()> { println!("Total declarations: {}", num_decls); println!("Total functions: {}", funcs.len()); let bar = indicatif::ProgressBar::new(funcs.len() as u64); + bar.set_style( + indicatif::ProgressStyle::default_bar().template("{wide_bar} {pos}/{len}\n{msg}"), + ); bar.tick(); let mut num_exprs = 0; let mut num_exprs_unknown = 0; let mut num_exprs_partially_unknown = 0; for f in funcs { let name = f.name(&db); + let mut msg = format!("processing: {}", name); if verbose { let (file_id, source) = f.source(&db); let original_file = file_id.original_file(&db); let path = db.file_relative_path(original_file); let syntax_range = source.syntax().range(); - println!("{} ({:?} {})", name, path, syntax_range); + write!(msg, " ({:?} {})", path, syntax_range).unwrap(); } + bar.set_message(&msg); if let Some(only_name) = only { if name.to_string() != only_name { continue; diff --git a/crates/ra_cli/src/main.rs b/crates/ra_cli/src/main.rs index 038f5f3fe6c..f11d0e6bd45 100644 --- a/crates/ra_cli/src/main.rs +++ b/crates/ra_cli/src/main.rs @@ -18,7 +18,7 @@ fn main() -> Result<()> { .subcommand(SubCommand::with_name("symbols")) .subcommand( SubCommand::with_name("analysis-stats") - .arg(Arg::with_name("verbose").short("v")) + .arg(Arg::with_name("verbose").short("v").long("verbose")) .arg(Arg::with_name("only").short("o").takes_value(true)) .arg(Arg::with_name("path")), )