Struct sourcemap::SourceMapIndex [] [src]

pub struct SourceMapIndex {
    // some fields omitted
}

Represents a sourcemap index in memory

Methods

impl SourceMapIndex
[src]

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

Creates a sourcemap index from a reader over a JSON stream in UTF-8 format. Optionally a "garbage header" as defined by the sourcemap draft specification is supported. In case a regular sourcemap is encountered an error is returned.

fn new(version: u32, file: Option<String>, sections: Vec<SourceMapSection>) -> SourceMapIndex

Constructs a new sourcemap index from raw components.

  • version: the version is typically 3 which is the current darft version
  • file: an optional filename of the index
  • sections: a vector of source map index sections

fn get_version(&self) -> u32

Returns the version of the sourcemap index.

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

Returns the embedded filename in case there is one.

fn get_section_count(&self) -> u32

Returns the number of sections in this index

fn get_section(&self, idx: u32) -> Option<&SourceMapSection>

Looks up a single section and returns it

fn get_section_mut(&mut self, idx: u32) -> Option<&mut SourceMapSection>

Looks up a single section and returns it as a mutable ref

fn sections<'a>(&'a self) -> SourceMapSectionIter<'a>

Iterates over all sections

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

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

This requires that the referenced sourcemaps are actually loaded. If a sourcemap is encountered that is not embedded but just externally referenced it is silently skipped.