MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / extract_inheritance

Method extract_inheritance

codegraph-kernel/src/tsjs/extractors.rs:1235–1270  ·  view source on GitHub ↗
(&mut self, node: Node<'t>, class_row: u32)

Source from the content-addressed store, hash-verified

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

Callers 3

extract_classMethod · 0.45
extract_interfaceMethod · 0.45
extract_enumMethod · 0.45

Calls 4

edge_kind_indexFunction · 0.85
textMethod · 0.65
unwrapMethod · 0.60
push_refMethod · 0.45

Tested by

no test coverage detected