pub struct SourceMap { /* private fields */ }Expand description
A listing of source files which are used to get parsed into an
UnresolvedPackage.
Implementations§
Source§impl SourceMap
impl SourceMap
Sourcepub fn push_file(&mut self, path: &Path) -> Result<()>
pub fn push_file(&mut self, path: &Path) -> Result<()>
Reads the file path on the filesystem and appends its contents to this
SourceMap.
Sourcepub fn push(&mut self, path: &Path, contents: impl Into<String>)
pub fn push(&mut self, path: &Path, contents: impl Into<String>)
Appends the given contents with the given path into this source map.
The path provided is not read from the filesystem and is instead only
used during error messages. Each file added to a SourceMap is
used to create the final parsed package namely by unioning all the
interfaces and worlds defined together. Note that each file has its own
personal namespace, however, for top-level use and such.
Sourcepub fn push_str(&mut self, path: &str, contents: impl Into<String>)
pub fn push_str(&mut self, path: &str, contents: impl Into<String>)
Appends the given contents with the given source name into this source map.
The path provided is not read from the filesystem and is instead only
used during error messages. Each file added to a SourceMap is
used to create the final parsed package namely by unioning all the
interfaces and worlds defined together. Note that each file has its own
personal namespace, however, for top-level use and such.
Sourcepub fn append(&mut self, other: SourceMap) -> u32
pub fn append(&mut self, other: SourceMap) -> u32
Appends all sources from another SourceMap into this one.
Returns the byte offset that should be added to all Span.start and
Span.end values from the appended source map to make them valid
in the combined source map.
Sourcepub fn parse(self) -> Result<UnresolvedPackageGroup>
pub fn parse(self) -> Result<UnresolvedPackageGroup>
Parses the files added to this source map into a
UnresolvedPackageGroup.
Sourcepub fn render_location(&self, span: Span) -> String
pub fn render_location(&self, span: Span) -> String
Renders a span as a human-readable location string (e.g., “file.wit:10:5”).
Sourcepub fn source_files(&self) -> impl Iterator<Item = &Path>
pub fn source_files(&self) -> impl Iterator<Item = &Path>
Returns an iterator over all filenames added to this source map.
Sourcepub fn source_names(&self) -> impl Iterator<Item = &str>
pub fn source_names(&self) -> impl Iterator<Item = &str>
Returns an iterator over all source names added to this source map.