pub struct SourceMap {
pub sources: Vec<SourceFile>,
pub entries: Vec<SourceMapEntry>,
}Expand description
Maps layout nodes to regions in source input files.
Fields§
§sources: Vec<SourceFile>Registered source files.
entries: Vec<SourceMapEntry>Node to source relationships. A node may have multiple entries.
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 new source file by name and returns its identifier.
Sourcepub fn intern_source(&mut self, name: impl Into<String>) -> SourceId
pub fn intern_source(&mut self, name: impl Into<String>) -> SourceId
Returns the existing source identifier for a name, or registers a new one.
Sourcepub fn add_entry(&mut self, node: NodeId, range: SourceRange, role: SourceRole)
pub fn add_entry(&mut self, node: NodeId, range: SourceRange, role: SourceRole)
Appends a source map entry linking a node to a source range.
Sourcepub fn source(&self, id: SourceId) -> Option<&SourceFile>
pub fn source(&self, id: SourceId) -> Option<&SourceFile>
Returns the source file for the given identifier.
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 all entries for the given node.
Sourcepub fn primary_range_for_node(&self, node: NodeId) -> Option<SourceRange>
pub fn primary_range_for_node(&self, node: NodeId) -> Option<SourceRange>
Returns the primary source range for the given node, if present.
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