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

Method extract_inheritance

codegraph-kernel/src/java.rs:987–1022  ·  view source on GitHub ↗

extractInheritance — the Java clauses (type_list-aware).

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

Source from the content-addressed store, hash-verified

985
986 /// extractInheritance — the Java clauses (type_list-aware).
987 fn extract_inheritance(&mut self, node: Node<'t>, class_row: u32) {
988 let extends_kind = edge_kind_index("extends").unwrap();
989 let implements_kind = edge_kind_index("implements").unwrap();
990 for i in 0..node.named_child_count() {
991 let Some(child) = node.named_child(i) else { continue };
992 match child.kind() {
993 "superclass" | "extends_interfaces" => {
994 let type_list = (0..child.named_child_count())
995 .filter_map(|j| child.named_child(j))
996 .find(|c| c.kind() == "type_list");
997 let targets: Vec<Node> = match type_list {
998 Some(tl) => (0..tl.named_child_count()).filter_map(|j| tl.named_child(j)).collect(),
999 None => child.named_child(0).into_iter().collect(),
1000 };
1001 for target in targets {
1002 let name = self.text(target).to_string();
1003 self.push_ref_at(class_row, &name, extends_kind, target);
1004 }
1005 }
1006 "super_interfaces" => {
1007 let type_list = (0..child.named_child_count())
1008 .filter_map(|j| child.named_child(j))
1009 .find(|c| c.kind() == "type_list");
1010 let targets: Vec<Node> = match type_list {
1011 Some(tl) => (0..tl.named_child_count()).filter_map(|j| tl.named_child(j)).collect(),
1012 None => (0..child.named_child_count()).filter_map(|j| child.named_child(j)).collect(),
1013 };
1014 for iface in targets {
1015 let name = self.text(iface).to_string();
1016 self.push_ref_at(class_row, &name, implements_kind, iface);
1017 }
1018 }
1019 _ => {}
1020 }
1021 }
1022 }
1023
1024 /// extractDecoratorsFor — Java annotations live inside `modifiers`.
1025 fn extract_decorators_for(&mut self, decl: Node<'t>, decorated_row: u32) {

Callers 3

extract_classMethod · 0.45
extract_interfaceMethod · 0.45
extract_enumMethod · 0.45

Calls 5

edge_kind_indexFunction · 0.85
textMethod · 0.65
unwrapMethod · 0.60
collectMethod · 0.45
push_ref_atMethod · 0.45

Tested by

no test coverage detected