Trait Files

pub trait Files {
    // Required method
    fn try_lookup_source_file(
        &self,
        raw_pos: BytePos,
    ) -> Result<Option<Arc<SourceFile>>, SourceMapLookupError>;

    // Provided methods
    fn map_raw_pos(&self, raw_pos: BytePos) -> BytePos { ... }
    fn is_in_file(&self, f: &Arc<SourceFile>, raw_pos: BytePos) -> bool { ... }
}
Available on crate features __ecma and __utils only.

Required Methods§

fn try_lookup_source_file( &self, raw_pos: BytePos, ) -> Result<Option<Arc<SourceFile>>, SourceMapLookupError>

raw_pos is the BytePos in the AST. It’s the raw value passed to the source map generator.

Provided Methods§

fn map_raw_pos(&self, raw_pos: BytePos) -> BytePos

This function is called to change the BytePos in AST into an unmapped, real value.

By default, it returns the raw value because by default, the AST stores original values.

fn is_in_file(&self, f: &Arc<SourceFile>, raw_pos: BytePos) -> bool

Check if the given byte position is within the given file. This has a good default implementation that will work for most cases.

The passed raw_pos is the value passed to Files::map_raw_pos.

Implementors§