pub struct SourceMap {
pub file: Option<String>,
pub source_root: Option<String>,
pub sources: Vec<String>,
pub sources_content: Vec<Option<String>>,
pub names: Vec<String>,
pub ignore_list: Vec<u32>,
/* private fields */
}Expand description
A parsed source map with O(log n) position lookups.
Fields§
§file: Option<String>§source_root: Option<String>§sources: Vec<String>§sources_content: Vec<Option<String>>§names: Vec<String>§ignore_list: Vec<u32>Implementations§
Source§impl SourceMap
impl SourceMap
Sourcepub fn from_json(json: &str) -> Result<Self, ParseError>
pub fn from_json(json: &str) -> Result<Self, ParseError>
Parse a source map from a JSON string. Supports both regular and indexed (sectioned) source maps.
Sourcepub fn original_position_for(
&self,
line: u32,
column: u32,
) -> Option<OriginalLocation>
pub fn original_position_for( &self, line: u32, column: u32, ) -> Option<OriginalLocation>
Look up the original source position for a generated position.
Both line and column are 0-based.
Returns None if no mapping exists or the mapping has no source.
Sourcepub fn generated_position_for(
&self,
source: &str,
line: u32,
column: u32,
) -> Option<GeneratedLocation>
pub fn generated_position_for( &self, source: &str, line: u32, column: u32, ) -> Option<GeneratedLocation>
Look up the generated position for an original source position.
source is the source filename. line and column are 0-based.
Sourcepub fn source_index(&self, name: &str) -> Option<u32>
pub fn source_index(&self, name: &str) -> Option<u32>
Find the source index for a filename.
Sourcepub fn mapping_count(&self) -> usize
pub fn mapping_count(&self) -> usize
Total number of decoded mappings.
Sourcepub fn line_count(&self) -> usize
pub fn line_count(&self) -> usize
Number of generated lines.
Sourcepub fn mappings_for_line(&self, line: u32) -> &[Mapping]
pub fn mappings_for_line(&self, line: u32) -> &[Mapping]
Get all mappings for a generated line (0-based).
Sourcepub fn all_mappings(&self) -> &[Mapping]
pub fn all_mappings(&self) -> &[Mapping]
Iterate all mappings.
Trait Implementations§
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