aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2019-05-07 11:09:10 +0100
committerFlorian Diebold <[email protected]>2019-05-07 12:45:29 +0100
commit880ef25a9e9fe3071181d27c6d8ea672bf76d680 (patch)
tree345036658dbb81fe3c1796a67a519617ae6e0218 /crates
parent4083caa233b03a390aca87e96e5bd290961df04c (diff)
Allow targeting a specific function with analysis-stats
This can be useful for debugging.
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_cli/src/analysis_stats.rs9
-rw-r--r--crates/ra_cli/src/main.rs7
2 files changed, 12 insertions, 4 deletions
diff --git a/crates/ra_cli/src/analysis_stats.rs b/crates/ra_cli/src/analysis_stats.rs
index 4516ed660..86ee0cb63 100644
--- a/crates/ra_cli/src/analysis_stats.rs
+++ b/crates/ra_cli/src/analysis_stats.rs
@@ -7,7 +7,7 @@ use ra_syntax::AstNode;
7 7
8use crate::Result; 8use crate::Result;
9 9
10pub fn run(verbose: bool) -> Result<()> { 10pub fn run(verbose: bool, only: Option<&str>) -> Result<()> {
11 let db_load_time = Instant::now(); 11 let db_load_time = Instant::now();
12 let (db, roots) = BatchDatabase::load_cargo(".")?; 12 let (db, roots) = BatchDatabase::load_cargo(".")?;
13 println!("Database loaded, {} roots, {:?}", roots.len(), db_load_time.elapsed()); 13 println!("Database loaded, {} roots, {:?}", roots.len(), db_load_time.elapsed());
@@ -57,14 +57,19 @@ pub fn run(verbose: bool) -> Result<()> {
57 let mut num_exprs_unknown = 0; 57 let mut num_exprs_unknown = 0;
58 let mut num_exprs_partially_unknown = 0; 58 let mut num_exprs_partially_unknown = 0;
59 for f in funcs { 59 for f in funcs {
60 let name = f.name(&db);
60 if verbose { 61 if verbose {
61 let (file_id, source) = f.source(&db); 62 let (file_id, source) = f.source(&db);
62 let original_file = file_id.original_file(&db); 63 let original_file = file_id.original_file(&db);
63 let path = db.file_relative_path(original_file); 64 let path = db.file_relative_path(original_file);
64 let syntax_range = source.syntax().range(); 65 let syntax_range = source.syntax().range();
65 let name = f.name(&db);
66 println!("{} ({:?} {})", name, path, syntax_range); 66 println!("{} ({:?} {})", name, path, syntax_range);
67 } 67 }
68 if let Some(only_name) = only {
69 if name.to_string() != only_name {
70 continue;
71 }
72 }
68 let body = f.body(&db); 73 let body = f.body(&db);
69 let inference_result = f.infer(&db); 74 let inference_result = f.infer(&db);
70 for (expr_id, _) in body.exprs() { 75 for (expr_id, _) in body.exprs() {
diff --git a/crates/ra_cli/src/main.rs b/crates/ra_cli/src/main.rs
index 45555be6e..11790d2e7 100644
--- a/crates/ra_cli/src/main.rs
+++ b/crates/ra_cli/src/main.rs
@@ -23,7 +23,9 @@ fn main() -> Result<()> {
23 .subcommand(SubCommand::with_name("parse").arg(Arg::with_name("no-dump").long("--no-dump"))) 23 .subcommand(SubCommand::with_name("parse").arg(Arg::with_name("no-dump").long("--no-dump")))
24 .subcommand(SubCommand::with_name("symbols")) 24 .subcommand(SubCommand::with_name("symbols"))
25 .subcommand( 25 .subcommand(
26 SubCommand::with_name("analysis-stats").arg(Arg::with_name("verbose").short("v")), 26 SubCommand::with_name("analysis-stats")
27 .arg(Arg::with_name("verbose").short("v"))
28 .arg(Arg::with_name("only").short("o").takes_value(true)),
27 ) 29 )
28 .get_matches(); 30 .get_matches();
29 match matches.subcommand() { 31 match matches.subcommand() {
@@ -51,7 +53,8 @@ fn main() -> Result<()> {
51 } 53 }
52 ("analysis-stats", Some(matches)) => { 54 ("analysis-stats", Some(matches)) => {
53 let verbose = matches.is_present("verbose"); 55 let verbose = matches.is_present("verbose");
54 analysis_stats::run(verbose)?; 56 let only = matches.value_of("only");
57 analysis_stats::run(verbose, only)?;
55 } 58 }
56 _ => unreachable!(), 59 _ => unreachable!(),
57 } 60 }