MCPcopy Create free account
hub / github.com/astral-sh/ruff / rewind

Method rewind

crates/ruff_python_parser/src/token_source.rs:202–210  ·  view source on GitHub ↗

Restore the token source to the given checkpoint.

(&mut self, checkpoint: TokenSourceCheckpoint)

Source from the content-addressed store, hash-verified

200
201 /// Restore the token source to the given checkpoint.
202 pub(crate) fn rewind(&mut self, checkpoint: TokenSourceCheckpoint) {
203 let TokenSourceCheckpoint {
204 lexer_checkpoint,
205 tokens_position,
206 } = checkpoint;
207
208 self.lexer.rewind(lexer_checkpoint);
209 self.tokens.truncate(tokens_position);
210 }
211
212 /// Returns a slice of [`Token`] that are within the given `range`.
213 pub(crate) fn in_range(&self, range: TextRange) -> &[Token] {

Callers 2

peekMethod · 0.45
peek2Method · 0.45

Calls 1

truncateMethod · 0.80

Tested by

no test coverage detected