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

Parses a list of match case blocks.

(&mut self)

Source from the content-addressed store, hash-verified

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

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