Extract a single const element.
(state: &mut ExtractionState, node: TsNode<'_>)
| 809 | |
| 810 | /// Extract a single const element. |
| 811 | fn visit_const_element(state: &mut ExtractionState, node: TsNode<'_>) { |
| 812 | let name = find_direct_child_by_kind(node, "name") |
| 813 | .map_or_else(|| "<anonymous>".to_string(), |n| state.node_text(n)); |
| 814 | |
| 815 | let start_line = node.start_position().row as u32; |
| 816 | let end_line = node.end_position().row as u32; |
| 817 | let start_column = node.start_position().column as u32; |
| 818 | let end_column = node.end_position().column as u32; |
| 819 | let qualified_name = format!("{}::{}", state.qualified_prefix(), name); |
| 820 | let id = generate_node_id(&state.file_path, &NodeKind::Const, &name, start_line); |
| 821 | |
| 822 | let graph_node = Node { |
| 823 | id: id.clone(), |
| 824 | kind: NodeKind::Const, |
| 825 | name: name.clone(), |
| 826 | qualified_name, |
| 827 | file_path: state.file_path.clone(), |
| 828 | start_line, |
| 829 | attrs_start_line: start_line, |
| 830 | end_line, |
| 831 | start_column, |
| 832 | end_column, |
| 833 | signature: Some(state.node_text(node).trim().to_string()), |
| 834 | docstring: None, |
| 835 | visibility: Visibility::Pub, |
| 836 | is_async: false, |
| 837 | branches: 0, |
| 838 | loops: 0, |
| 839 | returns: 0, |
| 840 | max_nesting: 0, |
| 841 | unsafe_blocks: 0, |
| 842 | unchecked_calls: 0, |
| 843 | assertions: 0, |
| 844 | updated_at: state.timestamp, |
| 845 | parent_id: None, |
| 846 | }; |
| 847 | state.nodes.push(graph_node); |
| 848 | |
| 849 | if let Some(parent_id) = state.parent_node_id() { |
| 850 | state.edges.push(Edge { |
| 851 | source: parent_id.to_string(), |
| 852 | target: id, |
| 853 | kind: EdgeKind::Contains, |
| 854 | line: Some(start_line), |
| 855 | }); |
| 856 | } |
| 857 | } |
| 858 | |
| 859 | /// Extract a property declaration inside a class. |
| 860 | fn visit_property_declaration(state: &mut ExtractionState, node: TsNode<'_>) { |
nothing calls this directly
no test coverage detected