pub trait ParserTrait {
type Checker: Alterator + Checker;
type Getter: Getter;
// Required methods
fn new(code: Vec<u8>, path: &Path, pr: Option<Arc<PreprocResults>>) -> Self;
fn root(&self) -> Node<'_>;
fn code(&self) -> &[u8] ⓘ;
fn filters(&self, requested: &[String]) -> Filter<'_>;
}Expand description
A parsed source in one language: the tree, its bytes, and the
Checker / Getter classifiers that read it.
Implemented once, generically, by Parser<T>
for every *Code tag; the per-language *Parser aliases in
langs are its concrete forms. This is the parse
half of a language: big-code-analysis layers the per-metric
implementations on top through its own supertrait, so nothing here
depends on a metric (#1376). Not an extension contract — implement
nothing; match on AnyParser to reach one.
Required Associated Types§
Required Methods§
Sourcefn new(code: Vec<u8>, path: &Path, pr: Option<Arc<PreprocResults>>) -> Self
fn new(code: Vec<u8>, path: &Path, pr: Option<Arc<PreprocResults>>) -> Self
Parses code read from path. pr carries the C-family
preprocessor results whose #defines are expanded before parsing;
every other language ignores it.
§Panics
When the language’s Cargo feature is disabled in this build —
there is no grammar to parse with and the signature is
infallible. Check LANG::is_enabled
first, or reach a parser through
AnyParser::parse, which
returns Err(MetricsError::LanguageDisabled) instead.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".