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:2738–2763  ·  view source on GitHub ↗

Parses a list of match case blocks.

(&mut self)

Source from the content-addressed store, hash-verified

2736
2737 /// Parses a list of match case blocks.
2738 fn parse_match_case_blocks(&mut self) -> Vec<ast::MatchCase> {
2739 let mut cases = vec![];
2740
2741 if !self.at(TokenKind::Case) {
2742 // test_err match_stmt_expected_case_block
2743 // match x:
2744 // x = 1
2745 // match x:
2746 // match y:
2747 // case _: ...
2748 self.add_error(
2749 ParseErrorType::OtherError("Expected `case` block".to_string()),
2750 self.current_token_range(),
2751 );
2752 return cases;
2753 }
2754
2755 let mut progress = ParserProgress::default();
2756
2757 while self.at(TokenKind::Case) {
2758 progress.assert_progressing(self);
2759 cases.push(self.parse_match_case());
2760 }
2761
2762 cases
2763 }
2764
2765 /// Parses a single match case block.
2766 ///

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