@@ -4,6 +4,7 @@ use std::path::Path;
44
55use fluent_syntax:: ast:: { Entry , Message , PatternElement } ;
66
7+ use crate :: diagnostics:: { CheckId , DiagCtx , RunningCheck } ;
78use crate :: walk:: { filter_dirs, walk} ;
89
910#[ rustfmt:: skip]
@@ -34,7 +35,7 @@ fn is_allowed_capitalized_word(msg: &str) -> bool {
3435 } )
3536}
3637
37- fn check_lowercase ( filename : & str , contents : & str , bad : & mut bool ) {
38+ fn check_lowercase ( filename : & str , contents : & str , check : & mut RunningCheck ) {
3839 let ( Ok ( parse) | Err ( ( parse, _) ) ) = fluent_syntax:: parser:: parse ( contents) ;
3940
4041 for entry in & parse. body {
@@ -45,20 +46,20 @@ fn check_lowercase(filename: &str, contents: &str, bad: &mut bool) {
4546 && value. chars ( ) . next ( ) . is_some_and ( char:: is_uppercase)
4647 && !is_allowed_capitalized_word ( value)
4748 {
48- tidy_error ! (
49- bad,
49+ check. error ( format ! (
5050 "{filename}: message `{value}` starts with an uppercase letter. Fix it or add it to `ALLOWED_CAPITALIZED_WORDS`"
51- ) ;
51+ ) ) ;
5252 }
5353 }
5454}
5555
56- pub fn check ( path : & Path , bad : & mut bool ) {
56+ pub fn check ( path : & Path , diag_ctx : DiagCtx ) {
57+ let mut check = diag_ctx. start_check ( CheckId :: new ( "fluent_lowercase" ) . path ( path) ) ;
5758 walk (
5859 path,
5960 |path, is_dir| filter_dirs ( path) || ( !is_dir && filter_fluent ( path) ) ,
6061 & mut |ent, contents| {
61- check_lowercase ( ent. path ( ) . to_str ( ) . unwrap ( ) , contents, bad ) ;
62+ check_lowercase ( ent. path ( ) . to_str ( ) . unwrap ( ) , contents, & mut check ) ;
6263 } ,
6364 ) ;
6465}
0 commit comments