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

Method parse_match_case_blocks

crates/ruff_python_parser/src/parser/statement.rs:2725–2750  ·  view source on GitHub ↗

Parses a list of match case blocks.

(&mut self)

Source from the content-addressed store, hash-verified

2723
2724 /// Parses a list of match case blocks.
2725 fn parse_match_case_blocks(&mut self) -> Vec<ast::MatchCase> {
2726 let mut cases = vec![];
2727
2728 if !self.at(TokenKind::Case) {
2729 // test_err match_stmt_expected_case_block
2730 // match x:
2731 // x = 1
2732 // match x:
2733 // match y:
2734 // case _: ...
2735 self.add_error(
2736 ParseErrorType::OtherError("Expected `case` block".to_string()),
2737 self.current_token_range(),
2738 );
2739 return cases;
2740 }
2741
2742 let mut progress = ParserProgress::default();
2743
2744 while self.at(TokenKind::Case) {
2745 progress.assert_progressing(self);
2746 cases.push(self.parse_match_case());
2747 }
2748
2749 cases
2750 }
2751
2752 /// Parses a single match case block.
2753 ///

Callers 1

parse_match_bodyMethod · 0.80

Calls 8

current_token_rangeMethod · 0.80
assert_progressingMethod · 0.80
parse_match_caseMethod · 0.80
defaultFunction · 0.50
atMethod · 0.45
add_errorMethod · 0.45
to_stringMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected