Struct sourcemap::SourceView

source ·
pub struct SourceView<'a> { /* private fields */ }
Expand description

Provides efficient access to minified sources.

This type is used to implement fairly efficient source mapping operations.

Implementations§

source§

impl<'a> SourceView<'a>

source

pub fn new(source: &'a str) -> SourceView<'a>

Creates an optimized view of a given source.

source

pub fn from_string(source: String) -> SourceView<'static>

Creates an optimized view from a given source string

source

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

Returns a requested minified line.

source

pub fn get_line_slice(&self, line: u32, col: u32, span: u32) -> Option<&str>

Returns a line slice.

Note that columns are indexed as JavaScript WTF-16 columns.

source

pub fn lines(&'a self) -> Lines<'a>

Returns an iterator over all lines.

source

pub fn source(&self) -> &str

Returns the source.

source

pub fn get_original_function_name<'map>( &self, token: Token<'map>, minified_name: &str ) -> Option<&'map str>

Given a token and minified function name this attemps to resolve the 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 line_count(&self) -> usize

Returns the number of lines.

source

pub fn sourcemap_reference(&self) -> Result<Option<SourceMapRef>>

Returns the source map reference in the source view.

Trait Implementations§

source§

impl<'a> Clone for SourceView<'a>

source§

fn clone(&self) -> SourceView<'a>

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<'a> Debug for SourceView<'a>

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> !Freeze for SourceView<'a>

§

impl<'a> RefUnwindSafe for SourceView<'a>

§

impl<'a> Send for SourceView<'a>

§

impl<'a> Sync for SourceView<'a>

§

impl<'a> Unpin for SourceView<'a>

§

impl<'a> UnwindSafe for SourceView<'a>

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> 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,

§

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>,

§

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>,

§

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.