Have the caller track stats here.
This commit is contained in:
parent
9f9f2a52b7
commit
16bd061b33
2 changed files with 15 additions and 11 deletions
|
|
@ -236,13 +236,15 @@ fn run() -> error::Result<()> {
|
|||
let mut has_error = false;
|
||||
loader.find_all_languages(&config.parser_directories)?;
|
||||
|
||||
let should_track_stats = matches.is_present("stat");
|
||||
let mut stats : parse::Stats = Default::default();
|
||||
|
||||
for path in paths {
|
||||
let path = Path::new(&path);
|
||||
let language =
|
||||
select_language(&mut loader, path, ¤t_dir, matches.value_of("scope"))?;
|
||||
has_error |= parse::parse_file_at_path(
|
||||
|
||||
let this_file_errored = parse::parse_file_at_path(
|
||||
language,
|
||||
path,
|
||||
&edits,
|
||||
|
|
@ -253,11 +255,19 @@ fn run() -> error::Result<()> {
|
|||
debug,
|
||||
debug_graph,
|
||||
allow_cancellation,
|
||||
&mut stats,
|
||||
)?;
|
||||
|
||||
if should_track_stats {
|
||||
stats.total_parses += 1;
|
||||
if !this_file_errored {
|
||||
stats.successful_parses += 1;
|
||||
}
|
||||
}
|
||||
|
||||
has_error |= this_file_errored;
|
||||
}
|
||||
|
||||
if matches.is_present("stat") {
|
||||
if should_track_stats {
|
||||
println!("{}", stats)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,8 +16,8 @@ pub struct Edit {
|
|||
|
||||
#[derive(Debug, Default)]
|
||||
pub struct Stats {
|
||||
successful_parses : usize,
|
||||
total_parses : usize,
|
||||
pub successful_parses : usize,
|
||||
pub total_parses : usize,
|
||||
}
|
||||
|
||||
impl fmt::Display for Stats {
|
||||
|
|
@ -41,7 +41,6 @@ pub fn parse_file_at_path(
|
|||
debug: bool,
|
||||
debug_graph: bool,
|
||||
allow_cancellation: bool,
|
||||
stats: &mut Stats,
|
||||
) -> Result<bool> {
|
||||
let mut _log_session = None;
|
||||
let mut parser = Parser::new();
|
||||
|
|
@ -178,11 +177,6 @@ pub fn parse_file_at_path(
|
|||
}
|
||||
}
|
||||
|
||||
stats.total_parses += 1;
|
||||
if first_error.is_none() {
|
||||
stats.successful_parses += 1;
|
||||
}
|
||||
|
||||
if first_error.is_some() || print_time {
|
||||
write!(
|
||||
&mut stdout,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue