[][src]Struct swc_js_sourcemap::SourceMapHermes

pub struct SourceMapHermes { /* fields omitted */ }

Represents a react-native-style SourceMap, which has additional scope information embedded.

Methods

impl SourceMapHermes[src]

pub fn from_reader<R: Read>(rdr: R) -> Result<Self>[src]

Creates a sourcemap from a reader over a JSON stream in UTF-8 format.

See SourceMap::from_reader

pub fn from_slice(slice: &[u8]) -> Result<Self>[src]

Creates a sourcemap from a reader over a JSON byte slice in UTF-8 format.

See SourceMap::from_slice

pub fn to_writer<W: Write>(&self, w: W) -> Result<()>[src]

Writes a sourcemap into a writer.

See SourceMap::to_writer

pub fn get_original_function_name(&self, bytecode_offset: u32) -> Option<&str>[src]

Given a bytecode offset, this will find the enclosing scopes function name.

pub fn rewrite(self, options: &RewriteOptions) -> Result<Self>[src]

This rewrites the sourcemap according to the provided rewrite options.

See SourceMap::rewrite

Methods from Deref<Target = SourceMap>

pub fn to_writer<W: Write>(&self, w: W) -> Result<()>[src]

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();

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_token(&self, idx: u32) -> Option<Token>[src]

Looks up a token by its index.

pub fn get_token_count(&self) -> u32[src]

Returns the number of tokens in the sourcemap.

Important traits for TokenIter<'a>
pub fn tokens(&self) -> TokenIter[src]

Returns an iterator over the tokens.

pub fn lookup_token(&self, line: u32, col: u32) -> Option<Token>[src]

Looks up the closest token to a given line and column.

pub fn get_original_function_name<'a>(
    &self,
    line: u32,
    col: u32,
    minified_name: &str,
    sv: &'a SourceView<'a>
) -> Option<&str>
[src]

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).

pub fn get_source_count(&self) -> u32[src]

Returns the number of sources in the sourcemap.

pub fn get_source(&self, idx: u32) -> Option<&str>[src]

Looks up a source for a specific index.

pub fn set_source(&mut self, idx: u32, value: &str)[src]

Sets a new source value for an index. This cannot add new sources.

This panics if a source is set that does not exist.

Important traits for SourceIter<'a>
pub fn sources(&self) -> SourceIter[src]

Iterates over all sources

pub fn get_source_view(&self, idx: u32) -> Option<&SourceView>[src]

Returns the sources content as source view.

pub fn get_source_contents(&self, idx: u32) -> Option<&str>[src]

Looks up the content for a source.

pub fn set_source_contents(&mut self, idx: u32, value: Option<&str>)[src]

Sets source contents for a source.

Important traits for SourceContentsIter<'a>
pub fn source_contents(&self) -> SourceContentsIter[src]

Iterates over all source contents

Important traits for NameIter<'a>
pub fn names(&self) -> NameIter[src]

Returns an iterator over the names.

pub fn get_name_count(&self) -> u32[src]

Returns the number of names in the sourcemap.

pub fn has_names(&self) -> bool[src]

Returns true if there are any names in the map.

pub fn get_name(&self, idx: u32) -> Option<&str>[src]

Looks up a name for a specific index.

pub fn remove_names(&mut self)[src]

Removes all names from the sourcemap.

pub fn get_index_size(&self) -> usize[src]

Returns the number of items in the index

Important traits for IndexIter<'a>
pub fn index_iter(&self) -> IndexIter[src]

Returns the number of items in the index

Trait Implementations

impl Deref for SourceMapHermes[src]

type Target = SourceMap

The resulting type after dereferencing.

impl DerefMut for SourceMapHermes[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.