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, (Self, ParseError)>
pub fn parse(self) -> Result<UnresolvedPackageGroup, (Self, ParseError)>
Parses the files added to this source map into a
UnresolvedPackageGroup.
On failure returns Err((self, e)) so the caller can use the source
map for error formatting if needed.
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.
Trait Implementations§
impl Eq for SourceMap
impl StructuralPartialEq for SourceMap
Auto Trait Implementations§
impl Freeze for SourceMap
impl RefUnwindSafe for SourceMap
impl Send for SourceMap
impl Sync for SourceMap
impl Unpin for SourceMap
impl UnsafeUnpin 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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.