SourceView

Struct SourceView 

Source
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>

Source

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>

Source§

fn clone(&self) -> SourceView<'view>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'view> Debug for SourceView<'view>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'view> From<&'view SourceText> for SourceView<'view>

Source§

fn from(value: &'view SourceText) -> Self

Converts to this type from the input type.
Source§

impl<'view> Hash for SourceView<'view>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<'view> PartialEq for SourceView<'view>

Source§

fn eq(&self, other: &SourceView<'view>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'view> Source for SourceView<'view>

Source§

fn length(&self) -> usize

Get the length of this source. Read more
Source§

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

Convert an offset to position information for error reporting. Read more
Source§

fn position_to_offset(&self, position: Position) -> usize

Convert a position to an offset. Read more
Source§

fn is_empty(&self) -> bool

Check if the source is empty.
Source§

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

Get the text from the current position to the end of the source. Read more
Source§

fn get_url(&self) -> Option<&Url>

Get the URL of this source, if available. Read more
Source§

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>

Converts an LSP Range to a byte-based source span. Read more
Source§

fn find_char_from(&self, offset: usize, ch: char) -> Option<usize>

Find the next occurrence of a character starting from an offset. Read more
Source§

fn find_str_from(&self, offset: usize, pattern: &str) -> Option<usize>

Find the next occurrence of a substring starting from an offset. Read more
Source§

fn syntax_error(&self, message: impl Into<String>, position: usize) -> OakError

Create an error for an invalid range. Read more
Source§

impl<'view> Eq for SourceView<'view>

Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> ErasedDestructor for T
where T: 'static,