(&mut self, node: Node<'t>, class_row: u32)
| 1230 | // --- extractInheritance (TS/JS clauses) --------------------------------------------------- |
| 1231 | |
| 1232 | pub(super) fn extract_inheritance(&mut self, node: Node<'t>, class_row: u32) { |
| 1233 | let extends_kind = edge_kind_index("extends").unwrap(); |
| 1234 | let implements_kind = edge_kind_index("implements").unwrap(); |
| 1235 | for i in 0..node.named_child_count() { |
| 1236 | let Some(child) = node.named_child(i) else { continue }; |
| 1237 | match child.kind() { |
| 1238 | // TS `extends_clause` (the other spellings are other grammars'). |
| 1239 | "extends_clause" | "superclass" | "base_clause" | "extends_interfaces" => { |
| 1240 | if let Some(target) = child.named_child(0) { |
| 1241 | let name = self.text(target).to_string(); |
| 1242 | self.push_ref(class_row, &name, extends_kind, target); |
| 1243 | } |
| 1244 | } |
| 1245 | "implements_clause" | "class_interface_clause" | "super_interfaces" | "interfaces" => { |
| 1246 | for j in 0..child.named_child_count() { |
| 1247 | if let Some(iface) = child.named_child(j) { |
| 1248 | let name = self.text(iface).to_string(); |
| 1249 | self.push_ref(class_row, &name, implements_kind, iface); |
| 1250 | } |
| 1251 | } |
| 1252 | } |
| 1253 | // JS `class Foo extends Bar` — class_heritage holds a bare |
| 1254 | // identifier without an extends_clause wrapper. |
| 1255 | "identifier" | "type_identifier" if node.kind() == "class_heritage" => { |
| 1256 | let name = self.text(child).to_string(); |
| 1257 | self.push_ref(class_row, &name, extends_kind, child); |
| 1258 | } |
| 1259 | // TS class_heritage wraps extends/implements — recurse. |
| 1260 | "field_declaration_list" | "class_heritage" => { |
| 1261 | self.extract_inheritance(child, class_row); |
| 1262 | } |
| 1263 | _ => {} |
| 1264 | } |
| 1265 | } |
| 1266 | } |
| 1267 | |
| 1268 | // --- type annotations (#381 — TS family only) ---------------------------------------------- |
| 1269 |
no test coverage detected