pub struct SourceMap { /* private fields */ }Expand description
A source mapping detached from a Program.
A source map records the file table, the program shape, and the
position-keyed spans of a span-bearing program. Extract it with
SourceMap::extract, carry it beside the emitted Workshop text, and
apply it to a program parsed from that text. Spans use
Position units: 1-based lines and columns counted in Unicode scalar
values.
The mapping granularity is rule, condition, action, direct action argument, and variable and subroutine declarations. Nodes without an authored origin have no entry, so consumers report evidence on them as unmapped.
Implementations§
Source§impl SourceMap
impl SourceMap
Sourcepub fn extract(program: &Program) -> Self
pub fn extract(program: &Program) -> Self
Extract the current mapping of a span-bearing program.
Only spans that are still valid for the program’s current shape are
extracted; see Program::rule_span.
Sourcepub fn files(&self) -> &[String]
pub fn files(&self) -> &[String]
The paths of the file table that mapped spans refer to by file index.
Sourcepub fn apply(&self, program: &mut Program) -> Result<(), SourceMapError>
pub fn apply(&self, program: &mut Program) -> Result<(), SourceMapError>
Replace the source mapping of program with this map.
The program’s file table becomes this map’s file table, and nodes
without an entry carry no span. The program must have exactly the shape
the map was extracted from; otherwise the whole mapping is rejected and
program is unchanged.