pub struct PositionMap { /* private fields */ }Expand description
Maps positions between a Shape source file and a virtual foreign document.
Implementations§
Source§impl PositionMap
impl PositionMap
pub fn new(body_span: Span, source: &str) -> Self
Sourcepub fn shape_to_virtual(&self, pos: Position) -> Option<Position>
pub fn shape_to_virtual(&self, pos: Position) -> Option<Position>
Map a Shape source position to virtual document position, if inside the body.
Sourcepub fn virtual_to_shape(&self, pos: Position) -> Option<Position>
pub fn virtual_to_shape(&self, pos: Position) -> Option<Position>
Map a virtual document position back to Shape source position.
Sourcepub fn virtual_range_to_shape(&self, range: Range) -> Option<Range>
pub fn virtual_range_to_shape(&self, range: Range) -> Option<Range>
Map a virtual document range back to a Shape source range.
Sourcepub fn body_start_offset(&self) -> usize
pub fn body_start_offset(&self) -> usize
The byte offset where the foreign body starts in the Shape source.
Sourcepub fn header_lines(&self) -> u32
pub fn header_lines(&self) -> u32
Number of synthetic header lines in the virtual document.
Trait Implementations§
Source§impl Clone for PositionMap
impl Clone for PositionMap
Source§fn clone(&self) -> PositionMap
fn clone(&self) -> PositionMap
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for PositionMap
impl RefUnwindSafe for PositionMap
impl Send for PositionMap
impl Sync for PositionMap
impl Unpin for PositionMap
impl UnsafeUnpin for PositionMap
impl UnwindSafe for PositionMap
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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