Extract a class specifier. Returns `(Entity, raw_name)` where `raw_name` is the unscoped name for use in building child scopes.
(
&self,
node: &Node,
source: &str,
file_path: &str,
scope: Option<&str>,
)
| 343 | /// Returns `(Entity, raw_name)` where `raw_name` is the unscoped name |
| 344 | /// for use in building child scopes. |
| 345 | fn extract_class( |
| 346 | &self, |
| 347 | node: &Node, |
| 348 | source: &str, |
| 349 | file_path: &str, |
| 350 | scope: Option<&str>, |
| 351 | ) -> Option<(Entity, String)> { |
| 352 | let name_node = node.child_by_field_name("name")?; |
| 353 | let name = self.node_text(&name_node, source); |
| 354 | |
| 355 | if name.is_empty() { |
| 356 | return None; |
| 357 | } |
| 358 | |
| 359 | let line = node.start_position().row as u32 + 1; |
| 360 | let end_line = node.end_position().row as u32 + 1; |
| 361 | |
| 362 | let full_name = match scope { |
| 363 | Some(s) => format!("{}::{}", s, name), |
| 364 | None => name.clone(), |
| 365 | }; |
| 366 | |
| 367 | let signature = format!("class {}", name); |
| 368 | |
| 369 | let mut entity = Entity::new(full_name, EntityKind::Class, file_path, line, end_line); |
| 370 | entity = entity.with_signature(signature); |
| 371 | entity.exported = true; |
| 372 | |
| 373 | Some((entity, name)) |
| 374 | } |
| 375 | |
| 376 | /// Extract a struct specifier. |
| 377 | /// |
no test coverage detected