pub struct SyntaxIrFile {
pub language: Language,
pub frontend_version: &'static str,
pub ir_schema_version: u32,
pub tokens: Vec<Token>,
pub signatures: Vec<(ByteRange, Signature)>,
pub roots: Vec<IrNode>,
pub diagnostics: Vec<Diagnostic>,
pub error_ranges: Vec<ByteRange>,
pub depth_truncated: bool,
pub test_module: bool,
}Expand description
The Syntax IR of one source file.
Fields§
§language: LanguageLanguage the file was parsed as.
frontend_version: &'static strVersion tag of the structural frontend that produced this IR; a fingerprint input.
ir_schema_version: u32IR schema version this file conforms to.
tokens: Vec<Token>Tokens in source order, comments and whitespace removed. Same representation as Fast mode, so token-level normalization is shared.
signatures: Vec<(ByteRange, Signature)>Function and method signatures keyed by their exact source range.
This is a reporting and semantic-evidence side table only. It is not read by structural or Fast fingerprint construction, so changing a signature never changes an existing structural identity.
roots: Vec<IrNode>Top-level IR nodes in source order.
diagnostics: Vec<Diagnostic>Recoverable lexical problems, as in Fast mode.
error_ranges: Vec<ByteRange>Source regions the parser marked as errors. Overlapping nodes are still emitted; these ranges only lower confidence downstream.
depth_truncated: boolWhether the frontend stopped descending after reaching its structural depth budget.
This is deliberately separate from Self::error_ranges: malformed
source is ordinary recovery, while a depth ceiling means the scan was
intentionally incomplete and must be reported as such.
test_module: boolWhether the file is the body of a module its tree declares test-only.
Not something a parse can answer: the declaration carrying the marker
is in another file, so this is settled once the whole set is known and
left here for the walk that reads a unit’s markers to start from. A
frontend leaves it false. See
declared_test_modules.
Implementations§
Source§impl SyntaxIrFile
impl SyntaxIrFile
Sourcepub fn signature_for_range(&self, range: ByteRange) -> Option<&Signature>
pub fn signature_for_range(&self, range: ByteRange) -> Option<&Signature>
Look up a signature by exact source range.
Sourcepub fn walk(&self, visit: &mut impl FnMut(&IrNode))
pub fn walk(&self, visit: &mut impl FnMut(&IrNode))
Depth-first pre-order traversal over every node in the file.
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Total number of nodes in the file.
Sourcepub fn unaccounted_tokens(&self) -> usize
pub fn unaccounted_tokens(&self) -> usize
Tokens the parser could not attach to any structure: those inside a
Shape::Error node that none of its children recovered.
This is the honest measure of what a parse lost, and
error_ranges is not. An error-tolerant parser
recovering from one bad construct routinely wraps everything around it
in a single error node: a header whose include guard encloses the file
gets one error region covering every byte of it, with the whole file’s
declarations intact inside. Measured over one project’s C++ sources,
the error regions covered 13.3% of the bytes while the tokens that
actually failed to parse were 1.82% — the difference is entirely code
the parser did read, sitting inside a region it had to open.
Nesting is not double-counted: an error node inside another is covered by its parent’s children, so the parent contributes only the gaps around it and the child contributes its own.