extractInheritance — the Go branches: interface embedding (a type_elem holding one named type; a union, `~T` or basic type is a constraint) and struct embedding (field_declaration without a field_identifier), plus the field_declaration_list recursion.
(&mut self, node: Node<'t>, class_row: u32)
| 1091 | /// and struct embedding (field_declaration without a field_identifier), |
| 1092 | /// plus the field_declaration_list recursion. |
| 1093 | fn extract_inheritance(&mut self, node: Node<'t>, class_row: u32) { |
| 1094 | stack_guard!(); |
| 1095 | let extends_kind = edge_kind_index("extends").unwrap(); |
| 1096 | for i in 0..node.named_child_count() { |
| 1097 | let Some(child) = node.named_child(i) else { continue }; |
| 1098 | match child.kind() { |
| 1099 | "type_elem" => { |
| 1100 | let mut terms = (0..child.named_child_count()) |
| 1101 | .filter_map(|j| child.named_child(j)) |
| 1102 | .filter(|c| c.kind() != "comment"); |
| 1103 | let only = match (terms.next(), terms.next()) { |
| 1104 | (Some(term), None) => Some(term), |
| 1105 | _ => None, |
| 1106 | }; |
| 1107 | if let Some(type_id) = self.embedded_type_name(only) { |
| 1108 | let name = self.text(type_id).to_string(); |
| 1109 | self.push_ref_at(class_row, &name, extends_kind, type_id); |
| 1110 | } |
| 1111 | } |
| 1112 | "field_declaration" => { |
| 1113 | let has_field_identifier = (0..child.named_child_count()) |
| 1114 | .filter_map(|j| child.named_child(j)) |
| 1115 | .any(|c| c.kind() == "field_identifier"); |
| 1116 | if !has_field_identifier { |
| 1117 | if let Some(type_id) = self.embedded_type_name(child.child_by_field_name("type")) { |
| 1118 | let name = self.text(type_id).to_string(); |
| 1119 | self.push_ref_at(class_row, &name, extends_kind, type_id); |
| 1120 | } |
| 1121 | } |
| 1122 | } |
| 1123 | "field_declaration_list" | "class_heritage" => { |
| 1124 | self.extract_inheritance(child, class_row); |
| 1125 | } |
| 1126 | _ => {} |
| 1127 | } |
| 1128 | } |
| 1129 | } |
| 1130 | |
| 1131 | /// extractTypeAnnotations — Go's returnField is `result`. |
| 1132 | fn extract_type_annotations(&mut self, node: Node<'t>, from_row: u32) { |
no test coverage detected