@@ -4,6 +4,7 @@ use std::path::Path;
44
55use fluent_syntax:: ast:: { Entry , PatternElement } ;
66
7+ use crate :: diagnostics:: { CheckId , DiagCtx , RunningCheck } ;
78use crate :: walk:: { filter_dirs, walk} ;
89
910fn filter_fluent ( path : & Path ) -> bool {
@@ -20,7 +21,7 @@ const ALLOWLIST: &[&str] = &[
2021 "incremental_corrupt_file" ,
2122] ;
2223
23- fn check_period ( filename : & str , contents : & str , bad : & mut bool ) {
24+ fn check_period ( filename : & str , contents : & str , check : & mut RunningCheck ) {
2425 if filename. contains ( "codegen" ) {
2526 // FIXME: Too many codegen messages have periods right now...
2627 return ;
@@ -40,7 +41,7 @@ fn check_period(filename: &str, contents: &str, bad: &mut bool) {
4041 if value. ends_with ( "." ) && !value. ends_with ( "..." ) {
4142 let ll = find_line ( contents, value) ;
4243 let name = m. id . name ;
43- tidy_error ! ( bad , "{filename}:{ll}: message `{name}` ends in a period" ) ;
44+ check . error ( format ! ( "{filename}:{ll}: message `{name}` ends in a period" ) ) ;
4445 }
4546 }
4647
@@ -56,7 +57,7 @@ fn check_period(filename: &str, contents: &str, bad: &mut bool) {
5657 {
5758 let ll = find_line ( contents, value) ;
5859 let name = attr. id . name ;
59- tidy_error ! ( bad , "{filename}:{ll}: attr `{name}` ends in a period" ) ;
60+ check . error ( format ! ( "{filename}:{ll}: attr `{name}` ends in a period" ) ) ;
6061 }
6162 }
6263 }
@@ -74,12 +75,14 @@ fn find_line(haystack: &str, needle: &str) -> usize {
7475 1
7576}
7677
77- pub fn check ( path : & Path , bad : & mut bool ) {
78+ pub fn check ( path : & Path , diag_ctx : DiagCtx ) {
79+ let mut check = diag_ctx. start_check ( CheckId :: new ( "fluent_period" ) . path ( path) ) ;
80+
7881 walk (
7982 path,
8083 |path, is_dir| filter_dirs ( path) || ( !is_dir && filter_fluent ( path) ) ,
8184 & mut |ent, contents| {
82- check_period ( ent. path ( ) . to_str ( ) . unwrap ( ) , contents, bad ) ;
85+ check_period ( ent. path ( ) . to_str ( ) . unwrap ( ) , contents, & mut check ) ;
8386 } ,
8487 ) ;
8588}
0 commit comments