pub struct SourceMap {
pub file_registry: FileRegistry,
/* private fields */
}Expand description
Maps byte offsets in expanded text back to original source locations.
The source map records one SourceOrigin per line of expanded output.
To resolve a byte offset from pest, we convert it to a line number
(by counting newlines), then look up the origin for that line.
Fields§
§file_registry: FileRegistryImplementations§
Source§impl SourceMap
impl SourceMap
pub fn new(file_registry: FileRegistry, line_origins: Vec<SourceOrigin>) -> Self
Sourcepub fn resolve(
&self,
byte_offset: usize,
expanded_source: &str,
) -> &SourceOrigin
pub fn resolve( &self, byte_offset: usize, expanded_source: &str, ) -> &SourceOrigin
Resolve a byte offset in the expanded source to its original location
Sourcepub fn resolve_span(
&self,
span: &Range<usize>,
expanded_source: &str,
) -> &SourceOrigin
pub fn resolve_span( &self, span: &Range<usize>, expanded_source: &str, ) -> &SourceOrigin
Remap a span (byte range) from expanded source to an original origin. Uses the start of the span for resolution.
pub fn is_empty(&self) -> bool
Sourcepub fn format_location(&self, origin: &SourceOrigin) -> String
pub fn format_location(&self, origin: &SourceOrigin) -> String
Format a human-readable location string for diagnostics
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 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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Converts
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>
Converts
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