pub struct Lowerer<'a> {
pub regexes: &'a RegexCache,
pub schema: &'a RepoPath,
pub findings: Vec<Finding>,
pub rule_ids: HashSet<String>,
pub lifecycle: Vec<LifecycleDimension>,
pub types: TypeRegistry,
}Expand description
The state of one lowering: the schema it reports on, what it found, and what it has read so far that later keys resolve against.
Fields§
§regexes: &'a RegexCacheThe cache the schema’s regexes compile through.
schema: &'a RepoPathThe schema that every finding is reported on.
findings: Vec<Finding>The findings so far.
rule_ids: HashSet<String>The rule-ids declared so far.
lifecycle: Vec<LifecycleDimension>The lifecycle, which only resolves against.
types: TypeRegistryThe types a template of this schema is written with.
Implementations§
Source§impl Lowerer<'_>
impl Lowerer<'_>
Sourcepub fn explained(
&mut self,
node: &Spanned,
shapes: &[&str],
format_speaks: bool,
)
pub fn explained( &mut self, node: &Spanned, shapes: &[&str], format_speaks: bool, )
A rule that declares a shape shows an example of it. A regex is a
shape and not an instruction, and the example is the one voice a rule
has: every failure it raises shows it, and the scaffold
writes it. A unit rule bound to a format takes the format’s, where
format_speaks; the format of a frontmatter value checks the value
and has no example. A rule that only selects, a count and a text
state nothing.
Sourcepub fn one_voice(&mut self, node: &Spanned)
pub fn one_voice(&mut self, node: &Spanned)
Guidance says what the example cannot, so the two holding one
sentence, or guidance that is one text of an example list, is
guidance that says nothing.
Sourcepub fn one_voice_in(
&mut self,
line: usize,
guidance: &str,
examples: impl IntoIterator<Item = String>,
)
pub fn one_voice_in( &mut self, line: usize, guidance: &str, examples: impl IntoIterator<Item = String>, )
As one_voice, for guidance and each of examples, which the
format gathers from wherever its scaffold writes them after it.
Source§impl Lowerer<'_>
impl Lowerer<'_>
Sourcepub fn shape(&mut self, node: &Spanned) -> Option<Shape>
pub fn shape(&mut self, node: &Spanned) -> Option<Shape>
The shape node declares, a failure reported on the schema.
Sourcepub fn check_key(
&mut self,
line: usize,
key: &str,
shape: Option<&Shape>,
format: Option<&Format>,
)
pub fn check_key( &mut self, line: usize, key: &str, shape: Option<&Shape>, format: Option<&Format>, )
A key names a hole or a named group of shape, or of every shape
of the format the rule binds.
Sourcepub fn frontmatter_constraint(
&mut self,
node: &Spanned,
key: &str,
) -> FrontmatterConstraint
pub fn frontmatter_constraint( &mut self, node: &Spanned, key: &str, ) -> FrontmatterConstraint
Grammar frontmatter-constraint, for the key key.
Source§impl<'a> Lowerer<'a>
impl<'a> Lowerer<'a>
Sourcepub fn new(
regexes: &'a RegexCache,
schema: &'a RepoPath,
types: TypeRegistry,
) -> Self
pub fn new( regexes: &'a RegexCache, schema: &'a RepoPath, types: TypeRegistry, ) -> Self
A lowering of a schema at schema, whose templates see types.
Sourcepub fn fail(
&mut self,
line: usize,
criterion: &'static str,
message: impl Into<String>,
)
pub fn fail( &mut self, line: usize, criterion: &'static str, message: impl Into<String>, )
A finding on the schema, at line, that breaks criterion.
Sourcepub fn fail_with(&mut self, line: usize, problem: Problem)
pub fn fail_with(&mut self, line: usize, problem: Problem)
A finding on the schema, at line, for problem.
Sourcepub fn regex(&self, node: &Spanned, key: &str) -> Option<Regex>
pub fn regex(&self, node: &Spanned, key: &str) -> Option<Regex>
The regex at key of node, checked where the grammar was read.
Sourcepub fn prohibitions(&self, node: &Spanned) -> Vec<Prohibition>
pub fn prohibitions(&self, node: &Spanned) -> Vec<Prohibition>
The prohibited-patterns of node.
Sourcepub fn only(&mut self, node: &Spanned) -> Only
pub fn only(&mut self, node: &Spanned) -> Only
The only of a rule, resolved against the lifecycle.
Sourcepub fn common(&mut self, node: &Spanned) -> RuleCommon
pub fn common(&mut self, node: &Spanned) -> RuleCommon
The keys every rule map carries: severity, and only.
Sourcepub fn lower_core(
&mut self,
yaml: &Spanned,
formats: FormatRegistry,
) -> CoreSchema
pub fn lower_core( &mut self, yaml: &Spanned, formats: FormatRegistry, ) -> CoreSchema
The keys of the core grammar of a schema: the lifecycle first, which
only resolves against, then the frontmatter, the bans and the
examples. formats is the registry the schema sees.