Extract a static item.
(&self, node: &Node, source: &str, file_path: &str)
| 322 | |
| 323 | /// Extract a static item. |
| 324 | fn extract_static(&self, node: &Node, source: &str, file_path: &str) -> Option<Entity> { |
| 325 | let name_node = node.child_by_field_name("name")?; |
| 326 | let name = self.node_text(&name_node, source); |
| 327 | |
| 328 | let line = node.start_position().row as u32 + 1; |
| 329 | let end_line = node.end_position().row as u32 + 1; |
| 330 | let exported = self.is_pub(node); |
| 331 | |
| 332 | let sig = self.first_line(node, source); |
| 333 | |
| 334 | let mut entity = Entity::new(name, EntityKind::Variable, file_path, line, end_line); |
| 335 | if let Some(s) = sig { |
| 336 | entity = entity.with_signature(s); |
| 337 | } |
| 338 | if exported { |
| 339 | entity.exported = true; |
| 340 | } |
| 341 | |
| 342 | Some(entity) |
| 343 | } |
| 344 | |
| 345 | /// Extract a mod declaration. |
| 346 | fn extract_mod(&self, node: &Node, source: &str, file_path: &str) -> Option<Entity> { |
no test coverage detected