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

Method parse_name

crates/ruff_python_parser/src/parser/expression.rs:536–551  ·  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

534 ///
535 /// See: <https://docs.python.org/3/reference/expressions.html#atom-identifiers>
536 pub(super) fn parse_name(&mut self, context: ExpressionContext) -> ast::ExprName {
537 let identifier = self.parse_identifier_with_context(context);
538
539 let ctx = if identifier.is_valid() {
540 ExprContext::Load
541 } else {
542 ExprContext::Invalid
543 };
544
545 ast::ExprName {
546 range: identifier.range,
547 id: identifier.id,
548 ctx,
549 node_index: AtomicNodeIndex::NONE,
550 }
551 }
552
553 pub(super) fn parse_missing_name(&mut self) -> ast::ExprName {
554 let identifier = self.parse_missing_identifier();

Callers 3

parse_atomMethod · 0.80

Calls 2

is_validMethod · 0.80

Tested by

no test coverage detected