Struct sourcemap::SourceMapIndex
source · pub struct SourceMapIndex { /* private fields */ }
Expand description
Represents a sourcemap index in memory
Implementations§
source§impl SourceMapIndex
impl SourceMapIndex
sourcepub fn from_reader<R: Read>(rdr: R) -> Result<SourceMapIndex>
pub fn from_reader<R: Read>(rdr: R) -> Result<SourceMapIndex>
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.
sourcepub fn from_slice(slice: &[u8]) -> Result<SourceMapIndex>
pub fn from_slice(slice: &[u8]) -> Result<SourceMapIndex>
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.
sourcepub fn new(
file: Option<String>,
sections: Vec<SourceMapSection>
) -> SourceMapIndex
pub fn new(
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
sourcepub fn new_ram_bundle_compatible(
file: Option<String>,
sections: Vec<SourceMapSection>,
x_facebook_offsets: Option<Vec<Option<u32>>>,
x_metro_module_paths: Option<Vec<String>>
) -> SourceMapIndex
pub fn new_ram_bundle_compatible(
file: Option<String>,
sections: Vec<SourceMapSection>,
x_facebook_offsets: Option<Vec<Option<u32>>>,
x_metro_module_paths: Option<Vec<String>>
) -> SourceMapIndex
Constructs a new sourcemap index from raw components including the facebook RAM bundle extensions.
file
: an optional filename of the indexsections
: a vector of source map index sectionsx_facebook_offsets
: a vector of facebook offsetsx_metro_module_paths
: a vector of metro module paths
sourcepub fn get_section_count(&self) -> u32
pub fn get_section_count(&self) -> u32
Returns the number of sections in this index
sourcepub fn get_section(&self, idx: u32) -> Option<&SourceMapSection>
pub fn get_section(&self, idx: u32) -> Option<&SourceMapSection>
Looks up a single section and returns it
sourcepub fn get_section_mut(&mut self, idx: u32) -> Option<&mut SourceMapSection>
pub fn get_section_mut(&mut self, idx: u32) -> Option<&mut SourceMapSection>
Looks up a single section and returns it as a mutable ref
sourcepub fn sections(&self) -> SourceMapSectionIter<'_> ⓘ
pub fn sections(&self) -> SourceMapSectionIter<'_> ⓘ
Iterates over all sections
sourcepub fn get_original_function_name<'a>(
&self,
line: u32,
col: u32,
minified_name: &str,
sv: &'a SourceView<'a>
) -> Option<&str>
pub fn get_original_function_name<'a>(
&self,
line: u32,
col: u32,
minified_name: &str,
sv: &'a SourceView<'a>
) -> Option<&str>
Given a location, name and minified source file resolve a minified name to an original function name.
This invokes some guesswork and requires access to the original minified source. This will not yield proper results for anonymous functions or functions that do not have clear function names. (For instance it’s recommended that dotted function names are not passed to this function).
sourcepub fn lookup_token(&self, line: u32, col: u32) -> Option<Token<'_>>
pub fn lookup_token(&self, line: u32, col: u32) -> Option<Token<'_>>
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.
sourcepub fn flatten(&self) -> Result<SourceMap>
pub fn flatten(&self) -> Result<SourceMap>
Flattens an indexed sourcemap into a regular one. This requires that all referenced sourcemaps are attached.
sourcepub fn flatten_and_rewrite(
self,
options: &RewriteOptions<'_>
) -> Result<SourceMap>
pub fn flatten_and_rewrite(
self,
options: &RewriteOptions<'_>
) -> Result<SourceMap>
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.
sourcepub fn is_for_ram_bundle(&self) -> bool
pub fn is_for_ram_bundle(&self) -> bool
Returns true
if this sourcemap is for a RAM bundle.
sourcepub fn x_facebook_offsets(&self) -> Option<&[Option<u32>]>
pub fn x_facebook_offsets(&self) -> Option<&[Option<u32>]>
Returns embeded x-facebook-offset values.
sourcepub fn x_metro_module_paths(&self) -> Option<&[String]>
pub fn x_metro_module_paths(&self) -> Option<&[String]>
Returns embedded metro module paths.
Trait Implementations§
source§impl Clone for SourceMapIndex
impl Clone for SourceMapIndex
source§fn clone(&self) -> SourceMapIndex
fn clone(&self) -> SourceMapIndex
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more