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

Method extract_inheritance

codegraph-kernel/src/kotlin.rs:1283–1319  ·  view source on GitHub ↗

extractInheritance — delegation_specifier: user_type ?? its constructor_invocation's user_type → FIRST type_identifier → ONE `extends` ref at the typeId (interfaces ride extends too; qualified supertypes take the FIRST segment — `com`; `by`-delegation emits NOTHING).

(&mut self, node: Node<'t>, class_row: u32)

Source from the content-addressed store, hash-verified

1281 /// supertypes take the FIRST segment — `com`; `by`-delegation emits
1282 /// NOTHING).
1283 fn extract_inheritance(&mut self, node: Node<'t>, class_row: u32) {
1284 let extends_kind = edge_kind_index("extends").unwrap();
1285 for i in 0..node.named_child_count() {
1286 let Some(child) = node.named_child(i) else { continue };
1287 if child.kind() != "delegation_specifier" {
1288 continue;
1289 }
1290 let user_type = (0..child.named_child_count())
1291 .filter_map(|j| child.named_child(j))
1292 .find(|c| c.kind() == "user_type");
1293 let ctor_inv = (0..child.named_child_count())
1294 .filter_map(|j| child.named_child(j))
1295 .find(|c| c.kind() == "constructor_invocation");
1296 let target = user_type.or(ctor_inv);
1297 let Some(target) = target else { continue };
1298 let type_id: Node = if target.kind() == "user_type" {
1299 (0..target.named_child_count())
1300 .filter_map(|j| target.named_child(j))
1301 .find(|c| c.kind() == "type_identifier")
1302 .unwrap_or(target)
1303 } else {
1304 // constructor_invocation → its user_type → first type_identifier
1305 let ut = (0..target.named_child_count())
1306 .filter_map(|j| target.named_child(j))
1307 .find(|c| c.kind() == "user_type");
1308 match ut {
1309 Some(ut) => (0..ut.named_child_count())
1310 .filter_map(|j| ut.named_child(j))
1311 .find(|c| c.kind() == "type_identifier")
1312 .unwrap_or(ut),
1313 None => target,
1314 }
1315 };
1316 let name = self.text(type_id).to_string();
1317 self.push_ref_at(class_row, &name, extends_kind, type_id);
1318 }
1319 }
1320
1321 /// extractDecoratorsFor — kotlin annotations inside `modifiers`:
1322 /// `@Marker` (user_type child) → decorates ref; `@Anno(args)`

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_ref_atMethod · 0.45

Tested by

no test coverage detected