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

Method extract_inheritance

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

1025
1026 /// extractInheritance — the Java clauses (type_list-aware).
1027 fn extract_inheritance(&mut self, node: Node<'t>, class_row: u32) {
1028 let extends_kind = edge_kind_index("extends").unwrap();
1029 let implements_kind = edge_kind_index("implements").unwrap();
1030 for child in node.named_children(&mut node.walk()) {
1031 match child.kind() {
1032 "superclass" | "extends_interfaces" => {
1033 let type_list = (0..child.named_child_count())
1034 .filter_map(|j| child.named_child(j))
1035 .find(|c| c.kind() == "type_list");
1036 let targets: Vec<Node> = match type_list {
1037 Some(tl) => (0..tl.named_child_count()).filter_map(|j| tl.named_child(j)).collect(),
1038 None => child.named_child(0).into_iter().collect(),
1039 };
1040 for target in targets {
1041 let name = self.supertype_name(target);
1042 self.push_ref_at(class_row, &name, extends_kind, target);
1043 }
1044 }
1045 "super_interfaces" => {
1046 let type_list = (0..child.named_child_count())
1047 .filter_map(|j| child.named_child(j))
1048 .find(|c| c.kind() == "type_list");
1049 let targets: Vec<Node> = match type_list {
1050 Some(tl) => (0..tl.named_child_count()).filter_map(|j| tl.named_child(j)).collect(),
1051 None => (0..child.named_child_count()).filter_map(|j| child.named_child(j)).collect(),
1052 };
1053 for iface in targets {
1054 let name = self.supertype_name(iface);
1055 self.push_ref_at(class_row, &name, implements_kind, iface);
1056 }
1057 }
1058 _ => {}
1059 }
1060 }
1061 }
1062
1063 /// supertypeName — a parameterized supertype (`generic_type`) by the name
1064 /// before its type arguments: `Store` for `implements Store<String>`.

Callers 3

extract_classMethod · 0.45
extract_interfaceMethod · 0.45
extract_enumMethod · 0.45

Calls 6

edge_kind_indexFunction · 0.85
unwrapMethod · 0.60
walkMethod · 0.45
collectMethod · 0.45
supertype_nameMethod · 0.45
push_ref_atMethod · 0.45

Tested by

no test coverage detected