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)
| 1077 | /// and struct embedding (field_declaration without a field_identifier), |
| 1078 | /// plus the field_declaration_list recursion. |
| 1079 | fn extract_inheritance(&mut self, node: Node<'t>, class_row: u32) { |
| 1080 | stack_guard!(); |
| 1081 | let extends_kind = edge_kind_index("extends").unwrap(); |
| 1082 | for child in node.named_children(&mut node.walk()) { |
| 1083 | match child.kind() { |
| 1084 | "type_elem" => { |
| 1085 | let mut terms = (0..child.named_child_count()) |
| 1086 | .filter_map(|j| child.named_child(j)) |
| 1087 | .filter(|c| c.kind() != "comment"); |
| 1088 | let only = match (terms.next(), terms.next()) { |
| 1089 | (Some(term), None) => Some(term), |
| 1090 | _ => None, |
| 1091 | }; |
| 1092 | if let Some(type_id) = self.embedded_type_name(only) { |
| 1093 | let name = self.text(type_id).to_string(); |
| 1094 | self.push_ref_at(class_row, &name, extends_kind, type_id); |
| 1095 | } |
| 1096 | } |
| 1097 | "field_declaration" => { |
| 1098 | let has_field_identifier = (0..child.named_child_count()) |
| 1099 | .filter_map(|j| child.named_child(j)) |
| 1100 | .any(|c| c.kind() == "field_identifier"); |
| 1101 | if !has_field_identifier { |
| 1102 | if let Some(type_id) = self.embedded_type_name(child.child_by_field_name("type")) { |
| 1103 | let name = self.text(type_id).to_string(); |
| 1104 | self.push_ref_at(class_row, &name, extends_kind, type_id); |
| 1105 | } |
| 1106 | } |
| 1107 | } |
| 1108 | "field_declaration_list" | "class_heritage" => { |
| 1109 | self.extract_inheritance(child, class_row); |
| 1110 | } |
| 1111 | _ => {} |
| 1112 | } |
| 1113 | } |
| 1114 | } |
| 1115 | |
| 1116 | /// extractTypeAnnotations — Go's returnField is `result`. |
| 1117 | fn extract_type_annotations(&mut self, node: Node<'t>, from_row: u32) { |
no test coverage detected