Extract an enum class.
(state: &mut ExtractionState, node: TsNode<'_>)
| 647 | |
| 648 | /// Extract an enum class. |
| 649 | fn visit_enum(state: &mut ExtractionState, node: TsNode<'_>) { |
| 650 | let name = Self::extract_class_name(state, node); |
| 651 | let visibility = Self::extract_visibility(node, state); |
| 652 | let docstring = Self::extract_kdoc(state, node); |
| 653 | let signature = Some(Self::extract_declaration_signature(state, node)); |
| 654 | let start_line = node.start_position().row as u32; |
| 655 | let end_line = node.end_position().row as u32; |
| 656 | let start_column = node.start_position().column as u32; |
| 657 | let end_column = node.end_position().column as u32; |
| 658 | let qualified_name = format!("{}::{}", state.qualified_prefix(), name); |
| 659 | let id = generate_node_id(&state.file_path, &NodeKind::Enum, &name, start_line); |
| 660 | |
| 661 | let graph_node = Node { |
| 662 | id: id.clone(), |
| 663 | kind: NodeKind::Enum, |
| 664 | name: name.clone(), |
| 665 | qualified_name, |
| 666 | file_path: state.file_path.clone(), |
| 667 | start_line, |
| 668 | attrs_start_line: start_line, |
| 669 | end_line, |
| 670 | start_column, |
| 671 | end_column, |
| 672 | signature, |
| 673 | docstring, |
| 674 | visibility, |
| 675 | is_async: false, |
| 676 | branches: 0, |
| 677 | loops: 0, |
| 678 | returns: 0, |
| 679 | max_nesting: 0, |
| 680 | unsafe_blocks: 0, |
| 681 | unchecked_calls: 0, |
| 682 | assertions: 0, |
| 683 | updated_at: state.timestamp, |
| 684 | parent_id: None, |
| 685 | }; |
| 686 | state.nodes.push(graph_node); |
| 687 | |
| 688 | if let Some(parent_id) = state.parent_node_id() { |
| 689 | state.edges.push(Edge { |
| 690 | source: parent_id.to_string(), |
| 691 | target: id.clone(), |
| 692 | kind: EdgeKind::Contains, |
| 693 | line: Some(start_line), |
| 694 | }); |
| 695 | } |
| 696 | |
| 697 | Self::extract_annotations_from_modifiers(state, node, &id); |
| 698 | |
| 699 | // Visit enum body to extract enum entries. |
| 700 | state.node_stack.push((name, id)); |
| 701 | state.class_depth += 1; |
| 702 | if let Some(body) = find_direct_child_by_kind(node, "enum_class_body") { |
| 703 | Self::visit_enum_body(state, body); |
| 704 | } |
| 705 | state.class_depth -= 1; |
| 706 | state.node_stack.pop(); |
nothing calls this directly
no test coverage detected