Struct sourcemap::SourceMapHermes
source · pub struct SourceMapHermes { /* private fields */ }
Expand description
Represents a react-native
-style SourceMap, which has additional scope
information embedded.
Implementations§
source§impl SourceMapHermes
impl SourceMapHermes
sourcepub fn from_reader<R: Read>(rdr: R) -> Result<Self>
pub fn from_reader<R: Read>(rdr: R) -> Result<Self>
Creates a sourcemap from a reader over a JSON stream in UTF-8 format.
sourcepub fn from_slice(slice: &[u8]) -> Result<Self>
pub fn from_slice(slice: &[u8]) -> Result<Self>
Creates a sourcemap from a reader over a JSON byte slice in UTF-8 format.
sourcepub fn get_original_function_name(&self, bytecode_offset: u32) -> Option<&str>
pub fn get_original_function_name(&self, bytecode_offset: u32) -> Option<&str>
Given a bytecode offset, this will find the enclosing scopes function name.
sourcepub fn get_scope_for_token(&self, token: Token<'_>) -> Option<&str>
pub fn get_scope_for_token(&self, token: Token<'_>) -> Option<&str>
Resolves the name of the enclosing function for the given Token
.
sourcepub fn rewrite(self, options: &RewriteOptions<'_>) -> Result<Self>
pub fn rewrite(self, options: &RewriteOptions<'_>) -> Result<Self>
This rewrites the sourcemap according to the provided rewrite options.
Methods from Deref<Target = SourceMap>§
sourcepub fn to_writer<W: Write>(&self, w: W) -> Result<()>
pub fn to_writer<W: Write>(&self, w: W) -> Result<()>
Writes a sourcemap into a writer.
Note that this operation will generate an equivalent sourcemap to the
one that was generated on load however there might be small differences
in the generated JSON and layout. For instance sourceRoot
will not
be set as upon parsing of the sourcemap the sources will already be
expanded.
let sm = SourceMap::from_reader(input).unwrap();
let mut output : Vec<u8> = vec![];
sm.to_writer(&mut output).unwrap();
sourcepub fn get_source_root(&self) -> Option<&str>
pub fn get_source_root(&self) -> Option<&str>
Returns the embedded source_root in case there is one.
sourcepub fn set_source_root<T: Into<String>>(&mut self, value: Option<T>)
pub fn set_source_root<T: Into<String>>(&mut self, value: Option<T>)
Sets a new value for the source_root.
sourcepub fn get_token_count(&self) -> u32
pub fn get_token_count(&self) -> u32
Returns the number of tokens in the sourcemap.
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 0-indexed line and column.
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 get_source_count(&self) -> u32
pub fn get_source_count(&self) -> u32
Returns the number of sources in the sourcemap.
sourcepub fn get_source(&self, idx: u32) -> Option<&str>
pub fn get_source(&self, idx: u32) -> Option<&str>
Looks up a source for a specific index.
sourcepub fn set_source(&mut self, idx: u32, value: &str)
pub fn set_source(&mut self, idx: u32, value: &str)
Sets a new source value for an index. This cannot add new sources.
This panics if a source is set that does not exist.
sourcepub fn sources(&self) -> SourceIter<'_> ⓘ
pub fn sources(&self) -> SourceIter<'_> ⓘ
Iterates over all sources
sourcepub fn get_source_view(&self, idx: u32) -> Option<&SourceView<'_>>
pub fn get_source_view(&self, idx: u32) -> Option<&SourceView<'_>>
Returns the sources content as source view.
sourcepub fn get_source_contents(&self, idx: u32) -> Option<&str>
pub fn get_source_contents(&self, idx: u32) -> Option<&str>
Looks up the content for a source.
sourcepub fn set_source_contents(&mut self, idx: u32, value: Option<&str>)
pub fn set_source_contents(&mut self, idx: u32, value: Option<&str>)
Sets source contents for a source.
sourcepub fn source_contents(&self) -> SourceContentsIter<'_> ⓘ
pub fn source_contents(&self) -> SourceContentsIter<'_> ⓘ
Iterates over all source contents
sourcepub fn get_name_count(&self) -> u32
pub fn get_name_count(&self) -> u32
Returns the number of names in the sourcemap.
sourcepub fn remove_names(&mut self)
pub fn remove_names(&mut self)
Removes all names from the sourcemap.
sourcepub fn get_index_size(&self) -> usize
pub fn get_index_size(&self) -> usize
Returns the number of items in the index
sourcepub fn index_iter(&self) -> IndexIter<'_> ⓘ
pub fn index_iter(&self) -> IndexIter<'_> ⓘ
Returns the number of items in the index
Trait Implementations§
source§impl Clone for SourceMapHermes
impl Clone for SourceMapHermes
source§fn clone(&self) -> SourceMapHermes
fn clone(&self) -> SourceMapHermes
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more