Trait PatternLinter

Source
pub trait PatternLinter: LSend {
    // Required methods
    fn pattern(&self) -> &dyn Pattern;
    fn match_to_lint(
        &self,
        matched_tokens: &[Token],
        source: &[char],
    ) -> Option<Lint>;
    fn description(&self) -> &str;
}
Expand description

A trait that searches for Patterns in Documents.

Makes use of TokenStringExt::iter_chunks to avoid matching across sentence or clause boundaries.

Required Methods§

Source

fn pattern(&self) -> &dyn Pattern

A simple getter for the pattern to be searched for.

Source

fn match_to_lint( &self, matched_tokens: &[Token], source: &[char], ) -> Option<Lint>

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.

Source

fn description(&self) -> &str

A user-facing description of what kinds of grammatical errors this rule looks for. It is usually shown in settings menus.

Implementations on Foreign Types§

Source§

impl<PL: PatternLinter + ?Sized> PatternLinter for Box<PL>

Source§

fn pattern(&self) -> &dyn Pattern

Source§

fn match_to_lint( &self, matched_tokens: &[Token], source: &[char], ) -> Option<Lint>

Source§

fn description(&self) -> &str

Implementors§