Trait Files

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

    // Provided methods
    fn map_raw_pos(&self, raw_pos: BytePos) -> BytePos { ... }
    fn is_in_file(&self, f: &Lrc<SourceFile>, raw_pos: BytePos) -> bool { ... }
}

Required Methods§

Source

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

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

Provided Methods§

Source

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.

Source

fn is_in_file(&self, f: &Lrc<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§