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

Method extract_inheritance

codegraph-kernel/src/java.rs:978–1013  ·  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

976
977 /// extractInheritance — the Java clauses (type_list-aware).
978 fn extract_inheritance(&mut self, node: Node<'t>, class_row: u32) {
979 let extends_kind = edge_kind_index("extends").unwrap();
980 let implements_kind = edge_kind_index("implements").unwrap();
981 for i in 0..node.named_child_count() {
982 let Some(child) = node.named_child(i) else { continue };
983 match child.kind() {
984 "superclass" | "extends_interfaces" => {
985 let type_list = (0..child.named_child_count())
986 .filter_map(|j| child.named_child(j))
987 .find(|c| c.kind() == "type_list");
988 let targets: Vec<Node> = match type_list {
989 Some(tl) => (0..tl.named_child_count()).filter_map(|j| tl.named_child(j)).collect(),
990 None => child.named_child(0).into_iter().collect(),
991 };
992 for target in targets {
993 let name = self.text(target).to_string();
994 self.push_ref_at(class_row, &name, extends_kind, target);
995 }
996 }
997 "super_interfaces" => {
998 let type_list = (0..child.named_child_count())
999 .filter_map(|j| child.named_child(j))
1000 .find(|c| c.kind() == "type_list");
1001 let targets: Vec<Node> = match type_list {
1002 Some(tl) => (0..tl.named_child_count()).filter_map(|j| tl.named_child(j)).collect(),
1003 None => (0..child.named_child_count()).filter_map(|j| child.named_child(j)).collect(),
1004 };
1005 for iface in targets {
1006 let name = self.text(iface).to_string();
1007 self.push_ref_at(class_row, &name, implements_kind, iface);
1008 }
1009 }
1010 _ => {}
1011 }
1012 }
1013 }
1014
1015 /// extractDecoratorsFor — Java annotations live inside `modifiers`.
1016 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
unwrapMethod · 0.60
collectMethod · 0.45
textMethod · 0.45
push_ref_atMethod · 0.45

Tested by

no test coverage detected