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

Method parse_name

crates/ruff_python_parser/src/parser/expression.rs:468–483  ·  view source on GitHub ↗

Parses a name. For an invalid name, the `id` field will be an empty string and the `ctx` field will be [`ExprContext::Invalid`]. See:

(&mut self, context: ExpressionContext)

Source from the content-addressed store, hash-verified

466 ///
467 /// See: <https://docs.python.org/3/reference/expressions.html#atom-identifiers>
468 pub(super) fn parse_name(&mut self, context: ExpressionContext) -> ast::ExprName {
469 let identifier = self.parse_identifier_with_context(context);
470
471 let ctx = if identifier.is_valid() {
472 ExprContext::Load
473 } else {
474 ExprContext::Invalid
475 };
476
477 ast::ExprName {
478 range: identifier.range,
479 id: identifier.id,
480 ctx,
481 node_index: AtomicNodeIndex::NONE,
482 }
483 }
484
485 pub(super) fn parse_missing_name(&mut self) -> ast::ExprName {
486 let identifier = self.parse_missing_identifier();

Calls 2

is_validMethod · 0.45

Tested by

no test coverage detected