pub struct ParserRegistry { /* private fields */ }Expand description
The active set of parsers. Feeds each line to every parser and
concatenates their entries. The Vec<Box<dyn CompilationParser>>
is the extensibility seam: built-in parsers, plus (CM.6) WASM-contributed
ones — a plugin implementing the error-parser world is registered here
as one more Box<dyn CompilationParser> and is indistinguishable from a
native parser downstream.
Implementations§
Source§impl ParserRegistry
impl ParserRegistry
Sourcepub fn new() -> Self
pub fn new() -> Self
An empty registry (no parsers). Prefer Self::with_builtins.
Sourcepub fn with_builtins() -> Self
pub fn with_builtins() -> Self
The default registry: the built-in cargo/rustc (multi-line) + gnu-style (single-line) parsers.
Sourcepub fn register(&mut self, parser: Box<dyn CompilationParser>)
pub fn register(&mut self, parser: Box<dyn CompilationParser>)
Add a parser to the active set. Order is preserved; each line is fed to parsers in registration order.
CM.6: plugin parsers register before Self::with_builtins’s
catch-all would claim a line, but after the format-specific natives.
The dedup in Self::feed is first-entry-wins per location, so a
plugin that recognises a line rustc also recognises does not displace
rustc’s richer entry — and a line only the plugin understands is still
its own.
Sourcepub fn register_before_catch_all(&mut self, parser: Box<dyn CompilationParser>)
pub fn register_before_catch_all(&mut self, parser: Box<dyn CompilationParser>)
CM.6: register a plugin parser, placed ahead of the catch-all.
with_builtins ends with GeneralParser, whose job is to salvage a
file:line:col out of anything. If a plugin registered after it, the
catch-all’s thin Info entry would win the dedup for every location
the plugin also matched, and the plugin’s severity and message would
be silently discarded — the plugin would look like it did nothing.
Sourcepub fn feed(&mut self, line: &str) -> Vec<ErrorEntry>
pub fn feed(&mut self, line: &str) -> Vec<ErrorEntry>
Feed one line to every registered parser and concatenate the
entries they complete. Deduplicates by (path, line, col) —
the FIRST entry for each location wins. Format-specific parsers
register first and produce richer metadata (severity, message);
the catch-all [crate::parsers::GeneralParser] registers last
and its Info/empty duplicates are silently dropped.