Struct cpp_synmap::SourceMap
[−]
[src]
pub struct SourceMap { /* fields omitted */ }
The SourceMap
is the primary entry point for synmap
. It maintains a
mapping between Span
objects and the original source files they were
parsed from.
Methods
impl SourceMap
[src]
fn new() -> SourceMap
[src]
Create a new SourceMap
object with no files inside of it.
fn add_crate_root<P: AsRef<Path>>(&mut self, path: P) -> Result<Crate>
[src]
Read and parse the passed-in file path as a crate root, recursively
parsing each of the submodules. Produces a syn Crate
object with
all submodules inlined.
Span
objects inside the resulting crate object are SourceMap
relative, and should be interpreted by passing to the other methods on
this type, such as locinfo
, source_text
, or filename
.
fn filename(&self, span: Span) -> Result<&Path>
[src]
Get the filename which contains the given span.
Fails if the span is invalid or spans multiple source files.
fn source_text(&self, span: Span) -> Result<&str>
[src]
Get the source text for the passed-in span.
Fails if the span is invalid or spans multiple source files.
fn locinfo(&self, span: Span) -> Result<LocInfo>
[src]
Get a LocInfo object for the passed-in span, containing line, column,
and file name information for the beginning and end of the span. The
path
field in the returned LocInfo struct will be a reference to a
canonical path.
Fails if the span is invalid or spans multiple source files.