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

Method expect

crates/ruff_python_parser/src/parser/mod.rs:652–666  ·  view source on GitHub ↗

Eat the current token if its of the expected kind, otherwise adds an appropriate error.

(&mut self, expected: TokenKind)

Source from the content-addressed store, hash-verified

650
651 /// Eat the current token if its of the expected kind, otherwise adds an appropriate error.
652 fn expect(&mut self, expected: TokenKind) -> bool {
653 if self.eat(expected) {
654 return true;
655 }
656
657 self.add_error(
658 ParseErrorType::ExpectedToken {
659 found: self.current_token_kind(),
660 expected,
661 },
662 self.current_token_range(),
663 );
664
665 false
666 }
667
668 fn add_error<T>(&mut self, error: ParseErrorType, ranged: T)
669 where

Callers 15

defaultMethod · 0.80
inner_mutMethod · 0.80
freezeMethod · 0.80
system_mutMethod · 0.80
to_jsonMethod · 0.80
search_root_registrationFunction · 0.80
push_prefix_regexMethod · 0.80
innerMethod · 0.80
inner_mutMethod · 0.80
handle_option_groupFunction · 0.80
handle_optionFunction · 0.80

Calls 4

current_token_kindMethod · 0.80
current_token_rangeMethod · 0.80
eatMethod · 0.45
add_errorMethod · 0.45

Tested by 15

search_root_registrationFunction · 0.64
try_stop_watchMethod · 0.64
take_watch_changesMethod · 0.64
moduleMethod · 0.64
setupFunction · 0.64
new_fileFunction · 0.64
directory_moved_to_trashFunction · 0.64
directory_renamedFunction · 0.64