sourcemap

Struct 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

source

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

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

See SourceMap::from_reader

source

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

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

See SourceMap::from_slice

source

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

Writes a sourcemap into a writer.

See SourceMap::to_writer

source

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

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

source

pub fn get_scope_for_token(&self, token: Token<'_>) -> Option<&str>

Resolves the name of the enclosing function for the given Token.

source

pub fn rewrite(self, options: &RewriteOptions<'_>) -> Result<Self>

This rewrites the sourcemap according to the provided rewrite options.

See SourceMap::rewrite

Methods from Deref<Target = SourceMap>§

source

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

pub fn get_debug_id(&self) -> Option<DebugId>

Returns the embedded debug id.

source

pub fn set_debug_id(&mut self, debug_id: Option<DebugId>)

Sets a new value for the debug id.

source

pub fn get_file(&self) -> Option<&str>

Returns the embedded filename in case there is one.

source

pub fn set_file<T: Into<String>>(&mut self, value: Option<T>)

Sets a new value for the file.

source

pub fn get_source_root(&self) -> Option<&str>

Returns the embedded source_root in case there is one.

source

pub fn set_source_root<T: Into<String>>(&mut self, value: Option<T>)

Sets a new value for the source_root.

source

pub fn get_token(&self, idx: u32) -> Option<Token<'_>>

Looks up a token by its index.

source

pub fn get_token_count(&self) -> u32

Returns the number of tokens in the sourcemap.

source

pub fn tokens(&self) -> TokenIter<'_>

Returns an iterator over the tokens.

source

pub fn lookup_token(&self, line: u32, col: u32) -> Option<Token<'_>>

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

source

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

source

pub fn get_source_count(&self) -> u32

Returns the number of sources in the sourcemap.

source

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

Looks up a source for a specific index.

source

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.

source

pub fn sources(&self) -> SourceIter<'_>

Iterates over all sources

source

pub fn get_source_view(&self, idx: u32) -> Option<&SourceView<'_>>

Returns the sources content as source view.

source

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

Looks up the content for a source.

source

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

Sets source contents for a source.

source

pub fn source_contents(&self) -> SourceContentsIter<'_>

Iterates over all source contents

source

pub fn names(&self) -> NameIter<'_>

Returns an iterator over the names.

source

pub fn get_name_count(&self) -> u32

Returns the number of names in the sourcemap.

source

pub fn has_names(&self) -> bool

Returns true if there are any names in the map.

source

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

Looks up a name for a specific index.

source

pub fn remove_names(&mut self)

Removes all names from the sourcemap.

source

pub fn get_index_size(&self) -> usize

Returns the number of items in the index

source

pub fn index_iter(&self) -> IndexIter<'_>

Returns the number of items in the index

Trait Implementations§

source§

impl Clone for SourceMapHermes

source§

fn clone(&self) -> SourceMapHermes

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for SourceMapHermes

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Deref for SourceMapHermes

source§

type Target = SourceMap

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl DerefMut for SourceMapHermes

source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> ErasedDestructor for T
where T: 'static,

source§

impl<T> MaybeSendSync for T