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