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

Method parent_statement

crates/ruff_python_semantic/src/model.rs:1639–1644  ·  view source on GitHub ↗
(&self, node_id: NodeId)

Source from the content-addressed store, hash-verified

1637 /// Given a [`Stmt`], return its parent, if any.
1638 #[inline]
1639 pub fn parent_statement(&self, node_id: NodeId) -> Option<&'a Stmt> {
1640 self.nodes
1641 .ancestor_ids(node_id)
1642 .filter_map(|id| self.nodes[id].as_statement())
1643 .nth(1)
1644 }
1645
1646 /// Given a [`NodeId`], return the [`NodeId`] of the parent statement, if any.
1647 pub fn parent_statement_id(&self, node_id: NodeId) -> Option<NodeId> {

Callers 7

move_importsFunction · 0.80
fix_importsFunction · 0.80
redefined_while_unusedFunction · 0.80
fix_by_removing_importsFunction · 0.80
remove_unused_variableFunction · 0.80

Calls 2

as_statementMethod · 0.80
ancestor_idsMethod · 0.45

Tested by

no test coverage detected