pub struct SourceMap {
pub sources: Vec<SourceFile>,
pub entries: Vec<SourceMapEntry>,
}Expand description
Source files and the enclosing construct spans of nodes.
Fields§
§sources: Vec<SourceFile>Registered source files, sources[i].id == SourceId(i).
entries: Vec<SourceMapEntry>Enclosing construct spans, innermost first per node.
Implementations§
Source§impl SourceMap
impl SourceMap
Sourcepub fn add_source(&mut self, name: impl Into<String>) -> SourceId
pub fn add_source(&mut self, name: impl Into<String>) -> SourceId
Registers a source file and returns its id.
Sourcepub fn intern_source(&mut self, name: impl Into<String>) -> SourceId
pub fn intern_source(&mut self, name: impl Into<String>) -> SourceId
Returns the id of a source file by name, registering it when new.
Sourcepub fn add_entry(&mut self, node: NodeId, range: SourceRange)
pub fn add_entry(&mut self, node: NodeId, range: SourceRange)
Records an enclosing construct span of a node.
Sourcepub fn source(&self, id: SourceId) -> Option<&SourceFile>
pub fn source(&self, id: SourceId) -> Option<&SourceFile>
Returns a registered source file.
Sourcepub fn entries_for_node(
&self,
node: NodeId,
) -> impl Iterator<Item = &SourceMapEntry>
pub fn entries_for_node( &self, node: NodeId, ) -> impl Iterator<Item = &SourceMapEntry>
Iterates the enclosing construct entries of a node.
Trait Implementations§
impl Eq for SourceMap
impl StructuralPartialEq for SourceMap
Auto Trait Implementations§
impl Freeze for SourceMap
impl RefUnwindSafe for SourceMap
impl Send for SourceMap
impl Sync for SourceMap
impl Unpin for SourceMap
impl UnsafeUnpin for SourceMap
impl UnwindSafe for SourceMap
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more