pub struct ErrorRecoveryContext { /* private fields */ }Expand description
Context for error recovery during parsing
Implementations§
Source§impl ErrorRecoveryContext
impl ErrorRecoveryContext
Sourcepub fn current_location(&self) -> (usize, usize)
pub fn current_location(&self) -> (usize, usize)
Get current line and column
Sourcepub fn current_range(&self, length: usize) -> TextRange
pub fn current_range(&self, length: usize) -> TextRange
Get a text range for the current position
Sourcepub fn push_context(&mut self, context: ParseContext)
pub fn push_context(&mut self, context: ParseContext)
Push a new parsing context
Sourcepub fn pop_context(&mut self)
pub fn pop_context(&mut self)
Pop the current parsing context
Sourcepub fn current_context(&self) -> ParseContext
pub fn current_context(&self) -> ParseContext
Get the current parsing context
Sourcepub fn create_error(
&self,
message: String,
length: usize,
kind: ParseErrorKind,
) -> PositionedParseError
pub fn create_error( &self, message: String, length: usize, kind: ParseErrorKind, ) -> PositionedParseError
Create a positioned error with current location
Sourcepub fn suggest_recovery(
&self,
expected: SyntaxKind,
found: Option<SyntaxKind>,
) -> RecoveryStrategy
pub fn suggest_recovery( &self, expected: SyntaxKind, found: Option<SyntaxKind>, ) -> RecoveryStrategy
Determine the best recovery strategy for the current error
Sourcepub fn find_sync_point(
&self,
tokens: &[(SyntaxKind, String)],
current: usize,
) -> usize
pub fn find_sync_point( &self, tokens: &[(SyntaxKind, String)], current: usize, ) -> usize
Find the next safe synchronization point
Sourcepub fn get_context_snippet(&self, range: TextRange) -> String
pub fn get_context_snippet(&self, range: TextRange) -> String
Get context information for error messages
Trait Implementations§
Source§impl Clone for ErrorRecoveryContext
impl Clone for ErrorRecoveryContext
Source§fn clone(&self) -> ErrorRecoveryContext
fn clone(&self) -> ErrorRecoveryContext
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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 ErrorRecoveryContext
impl RefUnwindSafe for ErrorRecoveryContext
impl Send for ErrorRecoveryContext
impl Sync for ErrorRecoveryContext
impl Unpin for ErrorRecoveryContext
impl UnsafeUnpin for ErrorRecoveryContext
impl UnwindSafe for ErrorRecoveryContext
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