Skip to content

Commit

Permalink
count method lines
Browse files Browse the repository at this point in the history
  • Loading branch information
Medowhill committed Jun 6, 2024
1 parent a50088b commit 3f3f39f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/tag_analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ pub struct Statistics {
pub analyzed_bodies: usize,
pub tagged_unions: usize,
pub tagged_structs: usize,
pub method_lines: usize,
pub preparation: usize,
pub may_analysis: usize,
pub must_analysis: usize,
Expand All @@ -67,14 +68,15 @@ impl std::fmt::Display for Statistics {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"{} {} {} {} {} {} {} {} {} {} {} {}",
"{} {} {} {} {} {} {} {} {} {} {} {} {}",
self.unions,
self.structs,
self.candidates,
self.bodies,
self.analyzed_bodies,
self.tagged_unions,
self.tagged_structs,
self.method_lines,
self.preparation,
self.may_analysis,
self.must_analysis,
Expand Down Expand Up @@ -627,6 +629,7 @@ pub fn analyze(tcx: TyCtxt<'_>, conf: &Config) -> Statistics {

stat.tagged_structs = tagged_structs.len();

let mut method_lines = 0;
let mut suggestions = Suggestions::new(source_map);
for (s, ts) in &tagged_structs {
let item = hir.expect_item(*s);
Expand Down Expand Up @@ -886,6 +889,7 @@ impl {} {{
field_methods,
if is_first_union { &get_tag_method } else { "" },
);
method_lines += code.split('\n').count();
suggestions.add(item.span, code);
}

Expand All @@ -894,9 +898,11 @@ impl {} {{
}
}",
);
method_lines += set_tag_method.split('\n').count();
let span = item.span.shrink_to_hi();
suggestions.add(span, set_tag_method);
}
stat.method_lines = method_lines;

let mut nums = Nums::default();
for item_id in hir.items() {
Expand Down

0 comments on commit 3f3f39f

Please sign in to comment.