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

Method node

crates/ty_python_core/src/ast_node_ref.rs:97–114  ·  view source on GitHub ↗
(&self, module_ref: &'ast ParsedModuleRef)

Source from the content-addressed store, hash-verified

95 /// different file, Python version, or Salsa revision than the module to which the node belongs.
96 #[track_caller]
97 pub fn node<'ast>(&self, module_ref: &'ast ParsedModuleRef) -> &'ast T {
98 #[cfg(debug_assertions)]
99 assert_eq!(
100 (
101 module_ref.module().file(),
102 module_ref.module().python_version()
103 ),
104 (self.file, self.python_version),
105 "an `AstNodeRef` cannot be used with a module parsed for a different file or Python version"
106 );
107 // The user guarantees that the module is from the same file, Python version, and Salsa
108 // revision, so the file contents cannot have changed.
109 module_ref
110 .get_by_index(self.index)
111 .try_into()
112 .ok()
113 .expect("AST indices should never change within the same revision")
114 }
115}
116
117impl<T> get_size2::GetSize for AstNodeRef<T> {}

Calls 3

expectMethod · 0.80
get_by_indexMethod · 0.80
okMethod · 0.45

Tested by

no test coverage detected