pub struct IncrementalCache<'pool, L: Language> {
pub pool: &'pool mut GreenBuilder<L>,
pub last_lex: Option<Vec<Token<L::SyntaxKind>>>,
pub last_parse: Option<Arc<GreenNode<L::SyntaxKind>>>,
}Expand description
Incremental cache for preserving old green trees and optional lexical caches.
This struct maintains state from previous parsing operations to enable incremental reparsing when source code changes. It stores the last lexed tokens and the last parsed green tree, allowing the parser to reuse unchanged portions of the kind tree.
Fields§
§pool: &'pool mut GreenBuilder<L>The green builder for constructing new nodes
last_lex: Option<Vec<Token<L::SyntaxKind>>>The tokens from the previous lexical analysis
last_parse: Option<Arc<GreenNode<L::SyntaxKind>>>The green tree from the previous parsing operation
Implementations§
Source§impl<'pool, L: Language> IncrementalCache<'pool, L>
impl<'pool, L: Language> IncrementalCache<'pool, L>
Sourcepub fn new(pool: &'pool mut GreenBuilder<L>) -> Self
pub fn new(pool: &'pool mut GreenBuilder<L>) -> Self
Sourcepub fn with_lexed(self, tokens: Vec<Token<L::SyntaxKind>>) -> Self
pub fn with_lexed(self, tokens: Vec<Token<L::SyntaxKind>>) -> Self
Sourcepub fn with_parsed(self, green: GreenNode<L::SyntaxKind>) -> Self
pub fn with_parsed(self, green: GreenNode<L::SyntaxKind>) -> Self
Sourcepub fn count_tokens(&self) -> usize
pub fn count_tokens(&self) -> usize
Get the total number of tokens in the cached lexical analysis.
§Returns
The number of tokens in the cache, or 0 if no tokens are cached
Trait Implementations§
Auto Trait Implementations§
impl<'pool, L> Freeze for IncrementalCache<'pool, L>
impl<'pool, L> RefUnwindSafe for IncrementalCache<'pool, L>
impl<'pool, L> Send for IncrementalCache<'pool, L>
impl<'pool, L> Sync for IncrementalCache<'pool, L>
impl<'pool, L> Unpin for IncrementalCache<'pool, L>
impl<'pool, L> !UnwindSafe for IncrementalCache<'pool, L>
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