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

Method new

crates/ty_python_core/src/ast_node_ref.rs:74–90  ·  view source on GitHub ↗

Creates a new `AstNodeRef` that references `node`. This method may panic or produce unspecified results if the provided module is from a different file, Python version, or Salsa revision than the module to which the node belongs.

(module_ref: &ParsedModuleRef, node: &T)

Source from the content-addressed store, hash-verified

72 /// This method may panic or produce unspecified results if the provided module is from a
73 /// different file, Python version, or Salsa revision than the module to which the node belongs.
74 pub fn new(module_ref: &ParsedModuleRef, node: &T) -> Self {
75 let index = node.node_index().load();
76 debug_assert_eq!(module_ref.get_by_index(index).try_into().ok(), Some(node));
77
78 Self {
79 index,
80 #[cfg(debug_assertions)]
81 file: module_ref.module().file(),
82 #[cfg(debug_assertions)]
83 python_version: module_ref.module().python_version(),
84 #[cfg(debug_assertions)]
85 kind: AnyNodeRef::from(node).kind(),
86 #[cfg(debug_assertions)]
87 range: node.range(),
88 _node: PhantomData,
89 }
90 }
91
92 /// Returns a reference to the wrapped node.
93 ///

Callers

nothing calls this directly

Calls 7

loadMethod · 0.45
node_indexMethod · 0.45
fileMethod · 0.45
moduleMethod · 0.45
python_versionMethod · 0.45
kindMethod · 0.45
rangeMethod · 0.45

Tested by

no test coverage detected