(&mut self, node: Node<'t>)
| 1264 | // --- extractors ---------------------------------------------------------- |
| 1265 | |
| 1266 | fn extract_function(&mut self, node: Node<'t>) { |
| 1267 | stack_guard!(); |
| 1268 | // Receiver present (out-of-line `Cls::method` def) → method instead. |
| 1269 | if self.variant == Variant::Cpp && self.receiver_type_of(node).is_some() { |
| 1270 | self.extract_method(node); |
| 1271 | return; |
| 1272 | } |
| 1273 | |
| 1274 | let name = self.extract_name(node); |
| 1275 | if name == "<anonymous>" { |
| 1276 | if let Some(body) = node.child_by_field_name("body") { |
| 1277 | self.visit_function_body(body); |
| 1278 | } |
| 1279 | return; |
| 1280 | } |
| 1281 | // Misparse artifacts: drop the node, still walk the body (#946/#1061). |
| 1282 | if self.is_misparsed_function(&name, node) { |
| 1283 | if let Some(body) = node.child_by_field_name("body") { |
| 1284 | self.visit_function_body(body); |
| 1285 | } |
| 1286 | return; |
| 1287 | } |
| 1288 | |
| 1289 | let extra = Extra { |
| 1290 | docstring: preceding_docstring(node, self.src), |
| 1291 | signature: self.constructor_signature(node), |
| 1292 | visibility: if self.variant == Variant::Cpp { self.visibility_of(node) } else { None }, |
| 1293 | return_type: self.return_type_of(node), |
| 1294 | ..Extra::default() |
| 1295 | }; |
| 1296 | let Some(row) = self.create_node("function", &name, node, extra) else { return }; |
| 1297 | // (extractTypeAnnotations + extractDecoratorsFor are structural no-ops |
| 1298 | // for c/cpp: not in TYPE_ANNOTATION_LANGUAGES, and the decorator node |
| 1299 | // kinds never appear as direct children/preceding siblings in these |
| 1300 | // grammars — `attribute` only occurs under attribute_declaration.) |
| 1301 | self.stack.push(Scope { row, kind: "function", name, qualified: None }); |
| 1302 | if let Some(body) = node.child_by_field_name("body") { |
| 1303 | self.visit_function_body(body); |
| 1304 | } |
| 1305 | self.stack.pop(); |
| 1306 | } |
| 1307 | |
| 1308 | fn extract_method(&mut self, node: Node<'t>) { |
| 1309 | stack_guard!(); |
no test coverage detected