pub struct SourceView<'view> { /* private fields */ }Expand description
A view into a portion of source text.
This struct represents a slice or window into a larger source text, allowing parsers to work with specific sections of code while maintaining proper position tracking and coordinate conversion.
Implementations§
Source§impl<'view> SourceView<'view>
impl<'view> SourceView<'view>
Sourcepub fn view(&self, range: Range<usize>) -> Self
pub fn view(&self, range: Range<usize>) -> Self
Creates a new view into a sub-range of this view.
This method allows creating nested views within existing views, enabling parsers to work with increasingly specific sections of code.
§Arguments
range- The relative range within this view to create a sub-view for
§Returns
A new SourceView representing the specified sub-range
Trait Implementations§
Source§impl<'view> Clone for SourceView<'view>
impl<'view> Clone for SourceView<'view>
Source§fn clone(&self) -> SourceView<'view>
fn clone(&self) -> SourceView<'view>
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 moreSource§impl<'view> Debug for SourceView<'view>
impl<'view> Debug for SourceView<'view>
Source§impl<'view> From<&'view SourceText> for SourceView<'view>
impl<'view> From<&'view SourceText> for SourceView<'view>
Source§fn from(value: &'view SourceText) -> Self
fn from(value: &'view SourceText) -> Self
Converts to this type from the input type.
Source§impl<'view> Hash for SourceView<'view>
impl<'view> Hash for SourceView<'view>
Source§impl<'view> PartialEq for SourceView<'view>
impl<'view> PartialEq for SourceView<'view>
Source§impl<'view> Source for SourceView<'view>
impl<'view> Source for SourceView<'view>
Source§fn get_text_in(&self, range: Range<usize>) -> &str
fn get_text_in(&self, range: Range<usize>) -> &str
Get the text content at the specified range. Read more
Source§fn offset_to_position(&self, offset: usize) -> Position
fn offset_to_position(&self, offset: usize) -> Position
Convert an offset to position information for error reporting. Read more
Source§fn position_to_offset(&self, position: Position) -> usize
fn position_to_offset(&self, position: Position) -> usize
Convert a position to an offset. Read more
Source§fn get_char_at(&self, offset: usize) -> Option<char>
fn get_char_at(&self, offset: usize) -> Option<char>
Get a single character at the specified offset. Read more
Source§fn get_text_from(&self, offset: usize) -> &str
fn get_text_from(&self, offset: usize) -> &str
Get the text from the current position to the end of the source. Read more
Source§fn span_to_lsp_range(&self, span: Range<usize>) -> Range
fn span_to_lsp_range(&self, span: Range<usize>) -> Range
Converts a byte range to an LSP Range. Read more
Source§fn lsp_range_to_span(&self, range: Range) -> Range<usize>
fn lsp_range_to_span(&self, range: Range) -> Range<usize>
Converts an LSP Range to a byte-based source span. Read more
Source§fn find_char_from(&self, offset: usize, ch: char) -> Option<usize>
fn find_char_from(&self, offset: usize, ch: char) -> Option<usize>
Find the next occurrence of a character starting from an offset. Read more
impl<'view> Eq for SourceView<'view>
impl<'view> StructuralPartialEq for SourceView<'view>
Auto Trait Implementations§
impl<'view> Freeze for SourceView<'view>
impl<'view> RefUnwindSafe for SourceView<'view>
impl<'view> Send for SourceView<'view>
impl<'view> Sync for SourceView<'view>
impl<'view> Unpin for SourceView<'view>
impl<'view> UnwindSafe for SourceView<'view>
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