Extract a namespace definition. 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>,
)
| 413 | /// Returns `(Entity, raw_name)` where `raw_name` is the unscoped name |
| 414 | /// for use in building child scopes. |
| 415 | fn extract_namespace( |
| 416 | &self, |
| 417 | node: &Node, |
| 418 | source: &str, |
| 419 | file_path: &str, |
| 420 | scope: Option<&str>, |
| 421 | ) -> Option<(Entity, String)> { |
| 422 | // Anonymous namespaces have no name child — skip them |
| 423 | let name_node = node.child_by_field_name("name")?; |
| 424 | let name = self.node_text(&name_node, source); |
| 425 | |
| 426 | if name.is_empty() { |
| 427 | return None; |
| 428 | } |
| 429 | |
| 430 | let line = node.start_position().row as u32 + 1; |
| 431 | let end_line = node.end_position().row as u32 + 1; |
| 432 | |
| 433 | let full_name = match scope { |
| 434 | Some(s) => format!("{}::{}", s, name), |
| 435 | None => name.clone(), |
| 436 | }; |
| 437 | |
| 438 | let signature = format!("namespace {}", name); |
| 439 | |
| 440 | let mut entity = Entity::new(full_name, EntityKind::Module, file_path, line, end_line); |
| 441 | entity = entity.with_signature(signature); |
| 442 | entity.exported = true; |
| 443 | |
| 444 | Some((entity, name)) |
| 445 | } |
| 446 | |
| 447 | /// Extract an enum specifier. |
| 448 | fn extract_enum( |
no test coverage detected