Add an ra_cli command that analyses all crates in the current workspace

... and prints various stats about how many expressions have a type etc.
This commit is contained in:
Florian Diebold 2019-02-09 18:27:11 +01:00
parent 43e52ac9e2
commit 6964a88e8c
9 changed files with 227 additions and 4 deletions

View file

@ -1,3 +1,5 @@
mod analysis_stats;
use std::{fs, io::Read, path::Path, time::Instant};
use clap::{App, Arg, SubCommand};
@ -5,10 +7,12 @@ use join_to_string::join;
use ra_ide_api_light::{extend_selection, file_structure, syntax_tree};
use ra_syntax::{SourceFile, TextRange, TreeArc, AstNode};
use tools::collect_tests;
use flexi_logger::Logger;
type Result<T> = ::std::result::Result<T, failure::Error>;
fn main() -> Result<()> {
Logger::with_env().start()?;
let matches = App::new("ra-cli")
.setting(clap::AppSettings::SubcommandRequiredElseHelp)
.subcommand(
@ -23,6 +27,9 @@ fn main() -> Result<()> {
.arg(Arg::with_name("start"))
.arg(Arg::with_name("end")),
)
.subcommand(
SubCommand::with_name("analysis-stats").arg(Arg::with_name("verbose").short("v")),
)
.get_matches();
match matches.subcommand() {
("parse", Some(matches)) => {
@ -56,6 +63,10 @@ fn main() -> Result<()> {
let sels = selections(&file, start, end);
println!("{}", sels)
}
("analysis-stats", Some(matches)) => {
let verbose = matches.is_present("verbose");
analysis_stats::run(verbose)?;
}
_ => unreachable!(),
}
Ok(())