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

Method parse_with_statement

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

Parses a `with` statement The given `start` offset is the start of either the `with` token or the `async` token if it's an async with statement. # Panics If the parser isn't positioned at a `with` token. See:

(&mut self, start: TextSize)

Source from the content-addressed store, hash-verified

2212 ///
2213 /// See: <https://docs.python.org/3/reference/compound_stmts.html#the-with-statement>
2214 fn parse_with_statement(&mut self, start: TextSize) -> ast::StmtWith {
2215 self.bump(TokenKind::With);
2216
2217 let mut items = self.parse_with_items();
2218 items.shrink_to_fit();
2219
2220 self.expect(TokenKind::Colon);
2221
2222 let body = self.parse_body(Clause::With);
2223
2224 ast::StmtWith {
2225 items,
2226 body,
2227 is_async: false,
2228 range: self.node_range(start),
2229 node_index: AtomicNodeIndex::NONE,
2230 }
2231 }
2232
2233 /// Parses a list of with items.
2234 ///

Callers 2

parse_statementMethod · 0.80
parse_async_statementMethod · 0.80

Calls 6

parse_with_itemsMethod · 0.80
expectMethod · 0.80
parse_bodyMethod · 0.80
node_rangeMethod · 0.80
bumpMethod · 0.45
shrink_to_fitMethod · 0.45

Tested by

no test coverage detected