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

Method extract_inheritance

codegraph-kernel/src/kotlin.rs:1124–1160  ·  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

1122 /// supertypes take the FIRST segment — `com`; `by`-delegation emits
1123 /// NOTHING).
1124 fn extract_inheritance(&mut self, node: Node<'t>, class_row: u32) {
1125 let extends_kind = edge_kind_index("extends").unwrap();
1126 for i in 0..node.named_child_count() {
1127 let Some(child) = node.named_child(i) else { continue };
1128 if child.kind() != "delegation_specifier" {
1129 continue;
1130 }
1131 let user_type = (0..child.named_child_count())
1132 .filter_map(|j| child.named_child(j))
1133 .find(|c| c.kind() == "user_type");
1134 let ctor_inv = (0..child.named_child_count())
1135 .filter_map(|j| child.named_child(j))
1136 .find(|c| c.kind() == "constructor_invocation");
1137 let target = user_type.or(ctor_inv);
1138 let Some(target) = target else { continue };
1139 let type_id: Node = if target.kind() == "user_type" {
1140 (0..target.named_child_count())
1141 .filter_map(|j| target.named_child(j))
1142 .find(|c| c.kind() == "type_identifier")
1143 .unwrap_or(target)
1144 } else {
1145 // constructor_invocation → its user_type → first type_identifier
1146 let ut = (0..target.named_child_count())
1147 .filter_map(|j| target.named_child(j))
1148 .find(|c| c.kind() == "user_type");
1149 match ut {
1150 Some(ut) => (0..ut.named_child_count())
1151 .filter_map(|j| ut.named_child(j))
1152 .find(|c| c.kind() == "type_identifier")
1153 .unwrap_or(ut),
1154 None => target,
1155 }
1156 };
1157 let name = self.text(type_id).to_string();
1158 self.push_ref_at(class_row, &name, extends_kind, type_id);
1159 }
1160 }
1161
1162 /// extractDecoratorsFor — kotlin annotations inside `modifiers`:
1163 /// `@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