Extract a struct definition.
(&self, node: &Node, source: &str, file_path: &str)
| 196 | |
| 197 | /// Extract a struct definition. |
| 198 | fn extract_struct(&self, node: &Node, source: &str, file_path: &str) -> Option<Entity> { |
| 199 | let name_node = node.child_by_field_name("name")?; |
| 200 | let name = self.node_text(&name_node, source); |
| 201 | |
| 202 | let line = node.start_position().row as u32 + 1; |
| 203 | let end_line = node.end_position().row as u32 + 1; |
| 204 | let exported = self.is_pub(node); |
| 205 | |
| 206 | let signature = self.build_struct_signature(node, source); |
| 207 | |
| 208 | let mut entity = Entity::new(name, EntityKind::Class, file_path, line, end_line); |
| 209 | if let Some(sig) = signature { |
| 210 | entity = entity.with_signature(sig); |
| 211 | } |
| 212 | if exported { |
| 213 | entity.exported = true; |
| 214 | } |
| 215 | |
| 216 | Some(entity) |
| 217 | } |
| 218 | |
| 219 | /// Extract an enum definition. |
| 220 | fn extract_enum(&self, node: &Node, source: &str, file_path: &str) -> Option<Entity> { |
no test coverage detected