Struct leo_span::source_map::SourceMap
source · pub struct SourceMap {
inner: RefCell<SourceMapInner>,
}
Expand description
The source map containing all recorded sources, methods to register new ones, and methods to query about spans in relation to recorded sources.
Fields§
§inner: RefCell<SourceMapInner>
The actual source map data.
Implementations§
source§impl SourceMap
impl SourceMap
sourcepub fn load_file(&self, path: &Path) -> Result<Rc<SourceFile>>
pub fn load_file(&self, path: &Path) -> Result<Rc<SourceFile>>
Loads the given path
and returns a SourceFile
for it.
sourcepub fn new_source(&self, source: &str, name: FileName) -> Rc<SourceFile>
pub fn new_source(&self, source: &str, name: FileName) -> Rc<SourceFile>
Registers source
under the given file name
, returning a SourceFile
back.
sourcefn find_source_file_index(&self, pos: BytePos) -> Option<usize>
fn find_source_file_index(&self, pos: BytePos) -> Option<usize>
Find the index for the source file containing pos
.
sourcefn find_source_file(&self, pos: BytePos) -> Option<Rc<SourceFile>>
fn find_source_file(&self, pos: BytePos) -> Option<Rc<SourceFile>>
Find the source file containing pos
.
sourcefn find_line_col(&self, pos: BytePos) -> Option<LineCol>
fn find_line_col(&self, pos: BytePos) -> Option<LineCol>
Finds line column info about a given pos
.
sourcepub fn span_to_location(&self, sp: Span) -> Option<SpanLocation>
pub fn span_to_location(&self, sp: Span) -> Option<SpanLocation>
Retrieves the location (source file, lines, columns) on the given span.
sourcepub fn span_to_string(&self, span: Span) -> String
pub fn span_to_string(&self, span: Span) -> String
Returns a displayable representation of the span
as a string.
sourcepub fn contents_of_span(&self, span: Span) -> Option<String>
pub fn contents_of_span(&self, span: Span) -> Option<String>
Returns the source contents that is spanned by span
.
sourcepub fn line_contents_of_span(&self, span: Span) -> Option<String>
pub fn line_contents_of_span(&self, span: Span) -> Option<String>
Returns the source contents of the lines that span
is within.
That is, if the span refers to x = 4
in the source code:
// Line 1 let x = 4; // Line 4
then the contents on lines 2 and 3 are returned.