Extract an enum variant from a `container_field` inside an enum.
(state: &mut ExtractionState, node: TsNode<'_>)
| 483 | |
| 484 | /// Extract an enum variant from a `container_field` inside an enum. |
| 485 | fn visit_enum_variant(state: &mut ExtractionState, node: TsNode<'_>) { |
| 486 | let name = node |
| 487 | .child_by_field_name("name") |
| 488 | .map_or_else(|| "<anonymous>".to_string(), |n| state.node_text(n)); |
| 489 | |
| 490 | let start_line = node.start_position().row as u32; |
| 491 | let end_line = node.end_position().row as u32; |
| 492 | let start_column = node.start_position().column as u32; |
| 493 | let end_column = node.end_position().column as u32; |
| 494 | let qualified_name = format!("{}::{}", state.qualified_prefix(), name); |
| 495 | let id = generate_node_id(&state.file_path, &NodeKind::EnumVariant, &name, start_line); |
| 496 | |
| 497 | let graph_node = Node { |
| 498 | id: id.clone(), |
| 499 | kind: NodeKind::EnumVariant, |
| 500 | name, |
| 501 | qualified_name, |
| 502 | file_path: state.file_path.clone(), |
| 503 | start_line, |
| 504 | attrs_start_line: start_line, |
| 505 | end_line, |
| 506 | start_column, |
| 507 | end_column, |
| 508 | signature: None, |
| 509 | docstring: None, |
| 510 | visibility: Visibility::Pub, |
| 511 | is_async: false, |
| 512 | branches: 0, |
| 513 | loops: 0, |
| 514 | returns: 0, |
| 515 | max_nesting: 0, |
| 516 | unsafe_blocks: 0, |
| 517 | unchecked_calls: 0, |
| 518 | assertions: 0, |
| 519 | updated_at: state.timestamp, |
| 520 | parent_id: None, |
| 521 | }; |
| 522 | state.nodes.push(graph_node); |
| 523 | |
| 524 | // Contains edge from parent (enum). |
| 525 | if let Some(parent_id) = state.parent_node_id() { |
| 526 | state.edges.push(Edge { |
| 527 | source: parent_id.to_string(), |
| 528 | target: id, |
| 529 | kind: EdgeKind::Contains, |
| 530 | line: Some(start_line), |
| 531 | }); |
| 532 | } |
| 533 | } |
| 534 | |
| 535 | // ---------------------------------- |
| 536 | // Const (plain) |
nothing calls this directly
no test coverage detected