(&mut self, node: Node<'t>)
| 1146 | } |
| 1147 | |
| 1148 | fn dispatch_node(&mut self, node: Node<'t>) { |
| 1149 | stack_guard!(); |
| 1150 | let kind = node.kind(); |
| 1151 | let mut skip_children = false; |
| 1152 | |
| 1153 | // C/C++ function-like macros become `constant` nodes carrying the |
| 1154 | // directive as their signature — a value, never a callee (#1838). |
| 1155 | // Mirrors tree-sitter.ts visitNode. |
| 1156 | if kind == "preproc_function_def" { |
| 1157 | if let Some(name_node) = node.child_by_field_name("name") { |
| 1158 | let name = self.text(name_node).to_string(); |
| 1159 | let signature = Some(self.text(node).trim().to_string()); |
| 1160 | self.create_node("constant", &name, node, Extra { signature, ..Extra::default() }); |
| 1161 | } |
| 1162 | return; |
| 1163 | } |
| 1164 | |
| 1165 | // C++ namespace blocks: prefix-only, no node (#1291/#1093). Anonymous |
| 1166 | // namespaces fall through to the generic walk. |
| 1167 | if self.variant == Variant::Cpp && kind == "namespace_definition" { |
| 1168 | let ns_name = node |
| 1169 | .child_by_field_name("name") |
| 1170 | .map(|n| self.text(n).to_string()) |
| 1171 | .unwrap_or_default(); |
| 1172 | if !ns_name.is_empty() { |
| 1173 | self.namespace_prefix.push(ns_name); |
| 1174 | for c in node.named_children(&mut node.walk()) { |
| 1175 | self.visit_node(c); |
| 1176 | } |
| 1177 | self.namespace_prefix.pop(); |
| 1178 | return; |
| 1179 | } |
| 1180 | } |
| 1181 | |
| 1182 | self.maybe_capture_fn_refs(node); |
| 1183 | |
| 1184 | if self.is_cpp_constructor_declaration(node) { |
| 1185 | self.extract_method(node); |
| 1186 | skip_children = true; |
| 1187 | } else if kind == "function_definition" { |
| 1188 | // functionTypes for both; cpp's methodTypes also lists it, so |
| 1189 | // inside a class-like scope it extracts as a method. |
| 1190 | if self.inside_class_like() && self.variant == Variant::Cpp { |
| 1191 | self.extract_method(node); |
| 1192 | } else { |
| 1193 | self.extract_function(node); |
| 1194 | } |
| 1195 | skip_children = true; |
| 1196 | } else if self.variant == Variant::Cpp && kind == "class_specifier" { |
| 1197 | self.extract_class(node); |
| 1198 | skip_children = true; |
| 1199 | } else if kind == "struct_specifier" { |
| 1200 | self.extract_aggregate(node, "struct"); |
| 1201 | skip_children = true; |
| 1202 | } else if kind == "union_specifier" { |
| 1203 | self.extract_aggregate(node, "union"); |
| 1204 | skip_children = true; |
| 1205 | } else if kind == "enum_specifier" { |
no test coverage detected