Offline, privacy-first grammar checker. Fast, open-source, Rust-powered
refactor: `OwnedExprExt::and_not` → `but_not` (#3399)
Andrew Dunbar56baf431c965
diff --git a/harper-core/src/expr/mod.rs b/harper-core/src/expr/mod.rsindex 3d0354d1c..7553e62df 100644--- a/harper-core/src/expr/mod.rs+++ b/harper-core/src/expr/mod.rs@@ -165,7 +165,7 @@ wherepub trait OwnedExprExt {fn or(self, other: impl Expr + 'static) -> FirstMatchOf;fn and(self, other: impl Expr + 'static) -> All;- fn and_not(self, other: impl Expr + 'static) -> All;+ fn but_not(self, other: impl Expr + 'static) -> All;fn or_longest(self, other: impl Expr + 'static) -> LongestMatchOf;}@@ -184,7 +184,7 @@ where}/// Returns an expression that matches only if the current one matches and the expression contained in `other` does not.- fn and_not(self, other: impl Expr + 'static) -> All {+ fn but_not(self, other: impl Expr + 'static) -> All {self.and(UnlessStep::new(other, |_tok: &Token, _src: &[char]| true))}diff --git a/harper-core/src/linting/arrive_to.rs b/harper-core/src/linting/arrive_to.rsindex f50c2cbd1..9653ac16d 100644--- a/harper-core/src/linting/arrive_to.rs+++ b/harper-core/src/linting/arrive_to.rs@@ -14,7 +14,7 @@ impl Default for ArriveTo {expr: SequenceExpr::word_set(&["arrive", "arrived", "arrives", "arriving"]).t_ws().t_aco("to")- .and_not(+ .but_not(SequenceExpr::anything().t_any().t_any()diff --git a/harper-core/src/linting/be_adjective_confusions.rs b/harper-core/src/linting/be_adjective_confusions.rsindex 381535679..3f1110314 100644--- a/harper-core/src/linting/be_adjective_confusions.rs+++ b/harper-core/src/linting/be_adjective_confusions.rs@@ -49,7 +49,7 @@ impl BeAdjectiveLinter {// and would cause false positives.// Future improvements could add "it" support with// more sophisticated context analysis.- .and_not(Word::new("it")),+ .but_not(Word::new("it")),verb,adjective,message,diff --git a/harper-core/src/linting/compound_nouns/compound_noun_after_det_adj.rs b/harper-core/src/linting/compound_nouns/compound_noun_after_det_adj.rsindex 299fa8cae..628956aa9 100644--- a/harper-core/src/linting/compound_nouns/compound_noun_after_det_adj.rs+++ b/harper-core/src/linting/compound_nouns/compound_noun_after_det_adj.rs@@ -31,7 +31,7 @@ impl Default for CompoundNounAfterDetAdj {.t_ws().then(is_content_word).t_ws()- .then(is_content_word.and_not(InflectionOfBe::default()));+ .then(is_content_word.but_not(InflectionOfBe::default()));let split_expr = Lrc::new(MergeableWords::new(|meta_closed, meta_open| {predicate(meta_closed, meta_open)diff --git a/harper-core/src/linting/crave_for.rs b/harper-core/src/linting/crave_for.rsindex e79bcf26d..5b27be19b 100644--- a/harper-core/src/linting/crave_for.rs+++ b/harper-core/src/linting/crave_for.rs@@ -29,7 +29,7 @@ impl Default for CraveFor {.t_aco("craving").t_ws().t_aco("for")- .and_not(Word::new("being")),+ .but_not(Word::new("being")),),]),}diff --git a/harper-core/src/linting/disjoint_prefixes.rs b/harper-core/src/linting/disjoint_prefixes.rsindex c726d2498..5f653fa02 100644--- a/harper-core/src/linting/disjoint_prefixes.rs+++ b/harper-core/src/linting/disjoint_prefixes.rs@@ -41,7 +41,7 @@ where.t_ws_h().then_kind_either(TokenKind::is_verb, TokenKind::is_noun).then_optional_hyphen()- .and_not(SequenceExpr::any_of(vec![+ .but_not(SequenceExpr::any_of(vec![// No trailing hyphen. Ex: Custom patterns take precedence over built-in patterns -> overbuiltBox::new(SequenceExpr::anything().t_any().t_any().then_hyphen()),// Don't merge "co op" whether separated by space or hyphen.diff --git a/harper-core/src/linting/ever_every.rs b/harper-core/src/linting/ever_every.rsindex 188656c23..2d58de19c 100644--- a/harper-core/src/linting/ever_every.rs+++ b/harper-core/src/linting/ever_every.rs@@ -25,7 +25,7 @@ impl Default for EverEvery {.then_subject_pronoun().t_ws().t_aco("every")- .and_not(SequenceExpr::anything().t_any().t_aco("it")),+ .but_not(SequenceExpr::anything().t_any().t_aco("it")),}}}diff --git a/harper-core/src/linting/modal_of.rs b/harper-core/src/linting/modal_of.rsindex d7d8ee511..52e316ec7 100644--- a/harper-core/src/linting/modal_of.rs+++ b/harper-core/src/linting/modal_of.rs@@ -20,7 +20,7 @@ impl Default for ModalOf {SequenceExpr::with(ModalVerb::default()).then_whitespace().t_aco("of")- .and_not(FirstMatchOf::new(vec![+ .but_not(FirstMatchOf::new(vec![Box::new(Word::new("can")),Box::new(Word::new_exact("May")),])),diff --git a/harper-core/src/linting/no_longer.rs b/harper-core/src/linting/no_longer.rsindex 8e6eb5a65..25d70b9f2 100644--- a/harper-core/src/linting/no_longer.rs+++ b/harper-core/src/linting/no_longer.rs@@ -23,7 +23,7 @@ impl Default for NoLonger {TokenKind::is_adjective,][..],))- .and_not(+ .but_not(SequenceExpr::anything().t_any().t_any()diff --git a/harper-core/src/linting/there_is_agreement.rs b/harper-core/src/linting/there_is_agreement.rsindex 5c8f2bcf9..91307cd61 100644--- a/harper-core/src/linting/there_is_agreement.rs+++ b/harper-core/src/linting/there_is_agreement.rs@@ -53,7 +53,7 @@ impl<D: Dictionary> ThereIsAgreement<D> {// reject singular nouns that are also: adjectives, "no", spelled numbers// TODO but this rejects "problem"// "two" etc. are sg. nouns even though they can also be plural quantifiers- let singular_noun = Lrc::new(SequenceExpr::default().then_singular_noun().and_not(+ let singular_noun = Lrc::new(SequenceExpr::default().then_singular_noun().but_not(FirstMatchOf::new(vec![Box::new(|t: &Token, s: &[char]| {t.kind.is_adjective()diff --git a/harper-core/src/linting/vicious_loop/mod.rs b/harper-core/src/linting/vicious_loop/mod.rsindex 8b9dddc7a..111a49d75 100644--- a/harper-core/src/linting/vicious_loop/mod.rs+++ b/harper-core/src/linting/vicious_loop/mod.rs@@ -30,7 +30,7 @@ fn build_expr(flag: Prefer) -> Box<dyn Expr> {match flag {Prefer::Circle => Box::new(- seq.and_not(+ seq.but_not(SequenceExpr::default().then_word_except(&["viscous"]).t_ws()@@ -38,7 +38,7 @@ fn build_expr(flag: Prefer) -> Box<dyn Expr> {),),Prefer::Cycle => Box::new(- seq.and_not(+ seq.but_not(SequenceExpr::default().then_word_except(&["viscous"]).t_ws()@@ -46,7 +46,7 @@ fn build_expr(flag: Prefer) -> Box<dyn Expr> {),),Prefer::DontCare => {- Box::new(seq.and_not(SequenceExpr::default().then_word_except(&["viscous"])))+ Box::new(seq.but_not(SequenceExpr::default().then_word_except(&["viscous"])))}}}