Extract an enum case as an `EnumVariant`.
(state: &mut ExtractionState, node: TsNode<'_>)
| 564 | |
| 565 | /// Extract an enum case as an `EnumVariant`. |
| 566 | fn visit_enum_case(state: &mut ExtractionState, node: TsNode<'_>) { |
| 567 | let name = find_direct_child_by_kind(node, "name") |
| 568 | .map_or_else(|| "<anonymous>".to_string(), |n| state.node_text(n)); |
| 569 | |
| 570 | let start_line = node.start_position().row as u32; |
| 571 | let end_line = node.end_position().row as u32; |
| 572 | let start_column = node.start_position().column as u32; |
| 573 | let end_column = node.end_position().column as u32; |
| 574 | let qualified_name = format!("{}::{}", state.qualified_prefix(), name); |
| 575 | let id = generate_node_id(&state.file_path, &NodeKind::EnumVariant, &name, start_line); |
| 576 | |
| 577 | let graph_node = Node { |
| 578 | id: id.clone(), |
| 579 | kind: NodeKind::EnumVariant, |
| 580 | name: name.clone(), |
| 581 | qualified_name, |
| 582 | file_path: state.file_path.clone(), |
| 583 | start_line, |
| 584 | attrs_start_line: start_line, |
| 585 | end_line, |
| 586 | start_column, |
| 587 | end_column, |
| 588 | signature: Some(state.node_text(node).trim().to_string()), |
| 589 | docstring: None, |
| 590 | visibility: Visibility::Pub, |
| 591 | is_async: false, |
| 592 | branches: 0, |
| 593 | loops: 0, |
| 594 | returns: 0, |
| 595 | max_nesting: 0, |
| 596 | unsafe_blocks: 0, |
| 597 | unchecked_calls: 0, |
| 598 | assertions: 0, |
| 599 | updated_at: state.timestamp, |
| 600 | parent_id: None, |
| 601 | }; |
| 602 | state.nodes.push(graph_node); |
| 603 | |
| 604 | if let Some(parent_id) = state.parent_node_id() { |
| 605 | state.edges.push(Edge { |
| 606 | source: parent_id.to_string(), |
| 607 | target: id, |
| 608 | kind: EdgeKind::Contains, |
| 609 | line: Some(start_line), |
| 610 | }); |
| 611 | } |
| 612 | } |
| 613 | |
| 614 | /// Extract a namespace definition. |
| 615 | fn visit_namespace(state: &mut ExtractionState, node: TsNode<'_>) { |
nothing calls this directly
no test coverage detected