[][src]Struct sourcemap::SourceMapBuilder

pub struct SourceMapBuilder { /* fields omitted */ }

Helper for sourcemap generation

This helper exists because generating and modifying SourceMap objects is generally not very comfortable. As a general aid this type can help.

Implementations

impl SourceMapBuilder[src]

pub fn new(file: Option<&str>) -> SourceMapBuilder[src]

Creates a new source map builder and sets the file.

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

Sets the file for the sourcemap (optional)

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

Returns the currently set file.

pub fn add_source(&mut self, src: &str) -> u32[src]

Registers a new source with the builder and returns the source ID.

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

Changes the source name for an already set source.

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

Looks up a source name for an ID.

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

Sets the source contents for an already existing source.

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

Returns the current source contents for a source.

pub fn has_source_contents(&self, src_id: u32) -> bool[src]

Checks if a given source ID has source contents available.

pub fn load_local_source_contents(
    &mut self,
    base_path: Option<&Path>
) -> Result<usize>
[src]

Loads source contents from locally accessible files if referenced accordingly. Returns the number of loaded source contents

pub fn add_name(&mut self, name: &str) -> u32[src]

Registers a name with the builder and returns the name ID.

pub fn add(
    &mut self,
    dst_line: u32,
    dst_col: u32,
    src_line: u32,
    src_col: u32,
    source: Option<&str>,
    name: Option<&str>
) -> RawToken
[src]

Adds a new mapping to the builder.

pub fn add_raw(
    &mut self,
    dst_line: u32,
    dst_col: u32,
    src_line: u32,
    src_col: u32,
    source: Option<u32>,
    name: Option<u32>
) -> RawToken
[src]

Adds a new mapping to the builder.

pub fn add_token(&mut self, token: &Token<'_>, with_name: bool) -> RawToken[src]

Shortcut for adding a new mapping based of an already existing token, optionally removing the name.

pub fn strip_prefixes<S: AsRef<str>>(&mut self, prefixes: &[S])[src]

Strips common prefixes from the sources in the builder

pub fn into_sourcemap(self) -> SourceMap[src]

Converts the builder into a sourcemap.

Auto Trait Implementations

impl RefUnwindSafe for SourceMapBuilder

impl Send for SourceMapBuilder

impl Sync for SourceMapBuilder

impl Unpin for SourceMapBuilder

impl UnwindSafe for SourceMapBuilder

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.