Struct sourcemap::SourceMapIndex
[−]
[src]
pub struct SourceMapIndex { /* fields omitted */ }Represents a sourcemap index in memory
Methods
impl SourceMapIndex[src]
pub fn from_reader<R: Read>(rdr: R) -> Result<SourceMapIndex>[src]
Creates a sourcemap index from a reader over a JSON stream in UTF-8 format. Optionally a "garbage header" as defined by the sourcemap draft specification is supported. In case a regular sourcemap is encountered an error is returned.
pub fn to_writer<W: Write>(&self, w: W) -> Result<()>[src]
Writes a sourcemap index into a writer.
pub fn from_slice(slice: &[u8]) -> Result<SourceMapIndex>[src]
Creates a sourcemap index from a reader over a JSON byte slice in UTF-8 format. Optionally a "garbage header" as defined by the sourcemap draft specification is supported. In case a regular sourcemap is encountered an error is returned.
pub fn new(
file: Option<String>,
sections: Vec<SourceMapSection>
) -> SourceMapIndex[src]
file: Option<String>,
sections: Vec<SourceMapSection>
) -> SourceMapIndex
Constructs a new sourcemap index from raw components.
file: an optional filename of the indexsections: a vector of source map index sections
pub fn get_file(&self) -> Option<&str>[src]
Returns the embedded filename in case there is one.
pub fn set_file(&mut self, value: Option<&str>)[src]
Sets a new value for the file.
pub fn get_section_count(&self) -> u32[src]
Returns the number of sections in this index
pub fn get_section(&self, idx: u32) -> Option<&SourceMapSection>[src]
Looks up a single section and returns it
pub fn get_section_mut(&mut self, idx: u32) -> Option<&mut SourceMapSection>[src]
Looks up a single section and returns it as a mutable ref
ⓘImportant traits for SourceMapSectionIter<'a>pub fn sections<'a>(&'a self) -> SourceMapSectionIter<'a>[src]
Iterates over all sections
pub fn lookup_token<'a>(&'a self, line: u32, col: u32) -> Option<Token<'a>>[src]
Looks up the closest token to a given line and column.
This requires that the referenced sourcemaps are actually loaded. If a sourcemap is encountered that is not embedded but just externally referenced it is silently skipped.
pub fn flatten(self) -> Result<SourceMap>[src]
Flattens an indexed sourcemap into a regular one. This requires that all referenced sourcemaps are attached.
pub fn flatten_and_rewrite(self, options: &RewriteOptions) -> Result<SourceMap>[src]
Flattens an indexed sourcemap into a regular one and automatically rewrites it. This is more useful than plain flattening as this will cause the sourcemap to be properly deduplicated.