Struct sourcemap::SourceMap [] [src]

pub struct SourceMap { /* fields omitted */ }

Represents a sourcemap in memory

This is always represents a regular "non-indexed" sourcemap. Particularly in case the from_reader method is used an index sourcemap will be rejected with an error on reading.

Methods

impl SourceMap
[src]

Creates a sourcemap 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 an indexed sourcemap is encountered an error is returned.

use sourcemap::SourceMap;
let input: &[_] = b"{
    \"version\":3,
    \"sources\":[\"coolstuff.js\"],
    \"names\":[\"x\",\"alert\"],
    \"mappings\":\"AAAA,GAAIA,GAAI,EACR,IAAIA,GAAK,EAAG,CACVC,MAAM\"
}";
let sm = SourceMap::from_reader(input).unwrap();

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

use sourcemap::SourceMap;
let input: &[_] = b"{
    \"version\":3,
    \"sources\":[\"coolstuff.js\"],
    \"names\":[\"x\",\"alert\"],
    \"mappings\":\"AAAA,GAAIA,GAAI,EACR,IAAIA,GAAK,EAAG,CACVC,MAAM\"
}";
let sm = SourceMap::from_slice(input).unwrap();

Constructs a new sourcemap from raw components.

  • version: the version is typically 3 which is the current darft version
  • file: an optional filename of the sourcemap
  • tokens: a list of raw tokens
  • index: a sorted mapping of line and column to token index
  • names: a vector of names
  • sources a vector of source filenames
  • sources_content optional source contents

Returns the version of the sourcemap.

Returns the embedded filename in case there is one.

Looks up a token by its index.

Returns the number of tokens in the sourcemap.

Returns an iterator over the tokens.

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

Returns the number of sources in the sourcemap.

Looks up a source for a specific index.

Looks up the content for a source.

Returns an iterator over the names.

Returns the number of names in the sourcemap.

Looks up a name for a specific index.

Returns the number of items in the index

Returns the number of items in the index