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

Method expect

crates/ruff_python_parser/src/parser/mod.rs:607–621  ·  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

605
606 /// Eat the current token if its of the expected kind, otherwise adds an appropriate error.
607 fn expect(&mut self, expected: TokenKind) -> bool {
608 if self.eat(expected) {
609 return true;
610 }
611
612 self.add_error(
613 ParseErrorType::ExpectedToken {
614 found: self.current_token_kind(),
615 expected,
616 },
617 self.current_token_range(),
618 );
619
620 false
621 }
622
623 fn add_error<T>(&mut self, error: ParseErrorType, ranged: T)
624 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