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

Method peek

crates/ruff_python_parser/src/token_source.rs:139–144  ·  view source on GitHub ↗

Returns the next non-trivia token without consuming it. Use [`peek2`] to get the next two tokens. [`peek2`]: TokenSource::peek2

(&mut self)

Source from the content-addressed store, hash-verified

137 ///
138 /// [`peek2`]: TokenSource::peek2
139 pub(crate) fn peek(&mut self) -> TokenKind {
140 let checkpoint = self.lexer.checkpoint();
141 let next = self.next_non_trivia_token();
142 self.lexer.rewind(checkpoint);
143 next
144 }
145
146 /// Returns the next two non-trivia tokens without consuming it.
147 ///

Callers 3

parse_cells_uncheckedFunction · 0.45
assert_start_boundaryMethod · 0.45
assert_end_boundaryMethod · 0.45

Calls 3

next_non_trivia_tokenMethod · 0.80
checkpointMethod · 0.45
rewindMethod · 0.45

Tested by 2

assert_start_boundaryMethod · 0.36
assert_end_boundaryMethod · 0.36