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)
| 1063 | /// and struct embedding (field_declaration without a field_identifier), |
| 1064 | /// plus the field_declaration_list recursion. |
| 1065 | fn extract_inheritance(&mut self, node: Node<'t>, class_row: u32) { |
| 1066 | stack_guard!(); |
| 1067 | let extends_kind = edge_kind_index("extends").unwrap(); |
| 1068 | for i in 0..node.named_child_count() { |
| 1069 | let Some(child) = node.named_child(i) else { continue }; |
| 1070 | match child.kind() { |
| 1071 | "type_elem" => { |
| 1072 | let mut terms = (0..child.named_child_count()) |
| 1073 | .filter_map(|j| child.named_child(j)) |
| 1074 | .filter(|c| c.kind() != "comment"); |
| 1075 | let only = match (terms.next(), terms.next()) { |
| 1076 | (Some(term), None) => Some(term), |
| 1077 | _ => None, |
| 1078 | }; |
| 1079 | if let Some(type_id) = self.embedded_type_name(only) { |
| 1080 | let name = self.text(type_id).to_string(); |
| 1081 | self.push_ref_at(class_row, &name, extends_kind, type_id); |
| 1082 | } |
| 1083 | } |
| 1084 | "field_declaration" => { |
| 1085 | let has_field_identifier = (0..child.named_child_count()) |
| 1086 | .filter_map(|j| child.named_child(j)) |
| 1087 | .any(|c| c.kind() == "field_identifier"); |
| 1088 | if !has_field_identifier { |
| 1089 | if let Some(type_id) = self.embedded_type_name(child.child_by_field_name("type")) { |
| 1090 | let name = self.text(type_id).to_string(); |
| 1091 | self.push_ref_at(class_row, &name, extends_kind, type_id); |
| 1092 | } |
| 1093 | } |
| 1094 | } |
| 1095 | "field_declaration_list" | "class_heritage" => { |
| 1096 | self.extract_inheritance(child, class_row); |
| 1097 | } |
| 1098 | _ => {} |
| 1099 | } |
| 1100 | } |
| 1101 | } |
| 1102 | |
| 1103 | /// extractTypeAnnotations — Go's returnField is `result`. |
| 1104 | fn extract_type_annotations(&mut self, node: Node<'t>, from_row: u32) { |
no test coverage detected