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
.
Sourcepub fn find_source_file(&self, pos: BytePos) -> Option<Rc<SourceFile>>
pub 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.
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more