11use harper_brill:: UPOS ;
22
3+ use crate :: CharStringExt ;
34use crate :: expr:: Expr ;
45use crate :: expr:: SequenceExpr ;
56use crate :: {
@@ -17,25 +18,27 @@ impl Default for NominalWants {
1718 fn default ( ) -> Self {
1819 fn is_applicable_pronoun ( tok : & Token , src : & [ char ] ) -> bool {
1920 if tok. kind . is_pronoun ( ) && tok. kind . is_upos ( UPOS :: PRON ) {
20- let pron = tok. span . get_content_string ( src) . to_lowercase ( ) ;
21- // "That" can act as two kinds of pronoun: demonstrative and relative.
22- // As a demonstrative pronoun, it's third person singular.
23- // As a relative pronoun, it's behaves as any person:
24- // I am the one that wants to. He is the one that wants to.
25- pron != "that"
21+ let pron = tok. span . get_content ( src) ;
22+ !pron. eq_any_ignore_ascii_case_chars ( & [
23+ // "That" can act as two kinds of pronoun: demonstrative and relative.
24+ // As a demonstrative pronoun, it's third person singular.
25+ // As a relative pronoun, it's behaves as any person:
26+ // I am the one that wants to. He is the one that wants to.
27+ & [ 't' , 'h' , 'a' , 't' ] ,
2628 // Personal pronouns have case. Object case personal pronouns
2729 // can come after "want":
2830 // Make them want to believe.
2931 // Note: "you" and "it" are both subject and object case.
30- && pron != "me"
31- && pron != "us"
32+ & [ 'm' , 'e' ] ,
33+ & [ 'u' , 's' ] ,
3234 // "you" is subject and object both OK before "want".
33- && pron != "him"
34- && pron != "her"
35+ & [ 'h' , 'i' , 'm' ] ,
36+ & [ 'h' , 'e' , 'r' ] ,
3537 // "it" is both subject and object. Subject before "wants", object before "want".
36- && pron != "it"
37- && pron != "them"
38- && pron != "who"
38+ & [ 'i' , 't' ] ,
39+ & [ 't' , 'h' , 'e' , 'm' ] ,
40+ & [ 'w' , 'h' , 'o' ] ,
41+ ] )
3942 } else {
4043 false
4144 }
@@ -82,14 +85,20 @@ impl ExprLinter for NominalWants {
8285
8386 let replacement_chars: Vec < char > = replacement. chars ( ) . collect ( ) ;
8487
85- if offender. span . get_content ( source) == replacement_chars. as_slice ( ) {
88+ let offender_span = offender. span ;
89+ let offender_chars = offender_span. get_content ( source) ;
90+
91+ if offender_chars. eq_ignore_ascii_case_chars ( & replacement_chars) {
8692 return None ;
8793 }
8894
8995 Some ( Lint {
90- span : offender . span ,
96+ span : offender_span ,
9197 lint_kind : LintKind :: Miscellaneous ,
92- suggestions : vec ! [ Suggestion :: ReplaceWith ( replacement_chars) ] ,
98+ suggestions : vec ! [ Suggestion :: replace_with_match_case(
99+ replacement_chars,
100+ offender_chars,
101+ ) ] ,
93102 message : format ! ( "Did you mean `{replacement}`?" ) ,
94103 priority : 55 ,
95104 } )
@@ -309,4 +318,12 @@ mod tests {
309318 NominalWants :: default ( ) ,
310319 ) ;
311320 }
321+
322+ #[ test]
323+ fn test_2007 ( ) {
324+ assert_no_lints (
325+ "### 🙌 **We Want to Hear From You!**" ,
326+ NominalWants :: default ( ) ,
327+ )
328+ }
312329}
0 commit comments