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

Parses a list of match case blocks.

(&mut self)

Source from the content-addressed store, hash-verified

2766
2767 /// Parses a list of match case blocks.
2768 fn parse_match_case_blocks(&mut self) -> Vec<ast::MatchCase> {
2769 let mut cases = vec![];
2770
2771 if !self.at(TokenKind::Case) {
2772 // test_err match_stmt_expected_case_block
2773 // match x:
2774 // x = 1
2775 // match x:
2776 // match y:
2777 // case _: ...
2778 self.add_error(
2779 ParseErrorType::OtherError("Expected `case` block".to_string()),
2780 self.current_token_range(),
2781 );
2782 return cases;
2783 }
2784
2785 let mut progress = ParserProgress::default();
2786
2787 while self.at(TokenKind::Case) {
2788 progress.assert_progressing(self);
2789 cases.push(self.parse_match_case());
2790 }
2791
2792 cases
2793 }
2794
2795 /// Parses a single match case block.
2796 ///

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