pub struct SourceMap { /* private fields */ }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.
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.
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.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for SourceMap
impl !RefUnwindSafe for SourceMap
impl !Send for SourceMap
impl !Sync for SourceMap
impl Unpin for SourceMap
impl UnwindSafe for SourceMap
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more