aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_cli/src/analysis_stats.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_cli/src/analysis_stats.rs')
-rw-r--r--crates/ra_cli/src/analysis_stats.rs40
1 files changed, 39 insertions, 1 deletions
diff --git a/crates/ra_cli/src/analysis_stats.rs b/crates/ra_cli/src/analysis_stats.rs
index 7e7e6c073..1fad5b233 100644
--- a/crates/ra_cli/src/analysis_stats.rs
+++ b/crates/ra_cli/src/analysis_stats.rs
@@ -1,7 +1,7 @@
1use std::{collections::HashSet, fmt::Write, path::Path, time::Instant}; 1use std::{collections::HashSet, fmt::Write, path::Path, time::Instant};
2 2
3use ra_db::SourceDatabase; 3use ra_db::SourceDatabase;
4use ra_hir::{Crate, HasSource, ImplItem, ModuleDef, Ty}; 4use ra_hir::{Crate, HasBodySource, HasSource, HirDisplay, ImplItem, ModuleDef, Ty, TypeWalk};
5use ra_syntax::AstNode; 5use ra_syntax::AstNode;
6 6
7use crate::Result; 7use crate::Result;
@@ -66,6 +66,7 @@ pub fn run(verbose: bool, memory_usage: bool, path: &Path, only: Option<&str>) -
66 let mut num_exprs = 0; 66 let mut num_exprs = 0;
67 let mut num_exprs_unknown = 0; 67 let mut num_exprs_unknown = 0;
68 let mut num_exprs_partially_unknown = 0; 68 let mut num_exprs_partially_unknown = 0;
69 let mut num_type_mismatches = 0;
69 for f in funcs { 70 for f in funcs {
70 let name = f.name(db); 71 let name = f.name(db);
71 let mut msg = format!("processing: {}", name); 72 let mut msg = format!("processing: {}", name);
@@ -100,6 +101,42 @@ pub fn run(verbose: bool, memory_usage: bool, path: &Path, only: Option<&str>) -
100 num_exprs_partially_unknown += 1; 101 num_exprs_partially_unknown += 1;
101 } 102 }
102 } 103 }
104 if let Some(mismatch) = inference_result.type_mismatch_for_expr(expr_id) {
105 num_type_mismatches += 1;
106 if verbose {
107 let src = f.expr_source(db, expr_id);
108 if let Some(src) = src {
109 // FIXME: it might be nice to have a function (on Analysis?) that goes from Source<T> -> (LineCol, LineCol) directly
110 let original_file = src.file_id.original_file(db);
111 let path = db.file_relative_path(original_file);
112 let line_index = host.analysis().file_line_index(original_file).unwrap();
113 let text_range = src
114 .ast
115 .either(|it| it.syntax().text_range(), |it| it.syntax().text_range());
116 let (start, end) = (
117 line_index.line_col(text_range.start()),
118 line_index.line_col(text_range.end()),
119 );
120 bar.println(format!(
121 "{} {}:{}-{}:{}: Expected {}, got {}",
122 path.display(),
123 start.line + 1,
124 start.col_utf16,
125 end.line + 1,
126 end.col_utf16,
127 mismatch.expected.display(db),
128 mismatch.actual.display(db)
129 ));
130 } else {
131 bar.println(format!(
132 "{}: Expected {}, got {}",
133 name,
134 mismatch.expected.display(db),
135 mismatch.actual.display(db)
136 ));
137 }
138 }
139 }
103 } 140 }
104 bar.inc(1); 141 bar.inc(1);
105 } 142 }
@@ -115,6 +152,7 @@ pub fn run(verbose: bool, memory_usage: bool, path: &Path, only: Option<&str>) -
115 num_exprs_partially_unknown, 152 num_exprs_partially_unknown,
116 (num_exprs_partially_unknown * 100 / num_exprs) 153 (num_exprs_partially_unknown * 100 / num_exprs)
117 ); 154 );
155 println!("Type mismatches: {}", num_type_mismatches);
118 println!("Inference: {:?}, {}", inference_time.elapsed(), ra_prof::memory_usage()); 156 println!("Inference: {:?}, {}", inference_time.elapsed(), ra_prof::memory_usage());
119 println!("Total: {:?}, {}", analysis_time.elapsed(), ra_prof::memory_usage()); 157 println!("Total: {:?}, {}", analysis_time.elapsed(), ra_prof::memory_usage());
120 158