Skip to content

Offline, privacy-first grammar checker. Fast, open-source, Rust-powered

refactor(core): use `LSend` in more places

Elijah Potter86d0db9ce839
diff --git a/harper-core/src/linting/mod.rs b/harper-core/src/linting/mod.rs
index ff634bc40..1206155ef 100644
--- a/harper-core/src/linting/mod.rs
+++ b/harper-core/src/linting/mod.rs
@@ -125,30 +125,14 @@ pub use whereas::Whereas;
pub use wordpress_dotcom::WordPressDotcom;
pub use wrong_quotes::WrongQuotes;
-use crate::Document;
+use crate::{Document, LSend};
/// A __stateless__ rule that searches documents for grammatical errors.
///
/// Commonly implemented via [`PatternLinter`].
///
/// See also: [`LintGroup`].
-#[cfg(not(feature = "concurrent"))]
-pub trait Linter {
- /// Analyzes a document and produces zero or more [`Lint`]s.
- /// We pass `self` mutably for caching purposes.
- fn lint(&mut self, document: &Document) -> Vec<Lint>;
- /// A user-facing description of what kinds of grammatical errors this rule looks for.
- /// It is usually shown in settings menus.
- fn description(&self) -> &str;
-}
-
-/// A __stateless__ rule that searches documents for grammatical errors.
-///
-/// Commonly implemented via [`PatternLinter`].
-///
-/// See also: [`LintGroup`].
-#[cfg(feature = "concurrent")]
-pub trait Linter: Send + Sync {
+pub trait Linter: LSend {
/// Analyzes a document and produces zero or more [`Lint`]s.
/// We pass `self` mutably for caching purposes.
fn lint(&mut self, document: &Document) -> Vec<Lint>;
diff --git a/harper-core/src/linting/pattern_linter.rs b/harper-core/src/linting/pattern_linter.rs
index 844db6aec..7ae30a536 100644
--- a/harper-core/src/linting/pattern_linter.rs
+++ b/harper-core/src/linting/pattern_linter.rs
@@ -2,7 +2,7 @@ use std::num::NonZeroUsize;
use lru::LruCache;
-use crate::{CharString, Document, Token, TokenStringExt, patterns::Pattern};
+use crate::{CharString, Document, LSend, Token, TokenStringExt, patterns::Pattern};
use super::{Lint, Linter};
@@ -10,26 +10,7 @@ use super::{Lint, Linter};
///
/// Makes use of [`TokenStringExt::iter_chunks`] to avoid matching across sentence or clause
/// boundaries.
-#[cfg(not(feature = "concurrent"))]
-pub trait PatternLinter {
- /// A simple getter for the pattern to be searched for.
- fn pattern(&self) -> &dyn Pattern;
- /// If any portions of a [`Document`] match [`Self::pattern`], they are passed through [`PatternLinter::match_to_lint`] to be
- /// transformed into a [`Lint`] for editor consumption.
- ///
- /// This function may return `None` to elect _not_ to produce a lint.
- fn match_to_lint(&self, matched_tokens: &[Token], source: &[char]) -> Option<Lint>;
- /// A user-facing description of what kinds of grammatical errors this rule looks for.
- /// It is usually shown in settings menus.
- fn description(&self) -> &str;
-}
-
-/// A trait that searches for [`Pattern`]s in [`Document`]s.
-///
-/// Makes use of [`TokenStringExt::iter_chunks`] to avoid matching across sentence or clause
-/// boundaries.
-#[cfg(feature = "concurrent")]
-pub trait PatternLinter: Send + Sync {
+pub trait PatternLinter: LSend {
/// A simple getter for the pattern to be searched for.
fn pattern(&self) -> &dyn Pattern;
/// If any portions of a [`Document`] match [`Self::pattern`], they are passed through [`PatternLinter::match_to_lint`] to be