Extract a constructor declaration.
(state: &mut ExtractionState, node: TsNode<'_>)
| 740 | |
| 741 | /// Extract a constructor declaration. |
| 742 | fn visit_constructor(state: &mut ExtractionState, node: TsNode<'_>) { |
| 743 | let name = Self::extract_name(state, node).unwrap_or_else(|| "<anonymous>".to_string()); |
| 744 | let visibility = Self::extract_java_visibility(node, state); |
| 745 | let docstring = Self::extract_java_docstring(state, node); |
| 746 | let signature = Some(Self::extract_declaration_signature(state, node)); |
| 747 | let start_line = node.start_position().row as u32; |
| 748 | let end_line = node.end_position().row as u32; |
| 749 | let start_column = node.start_position().column as u32; |
| 750 | let end_column = node.end_position().column as u32; |
| 751 | let qualified_name = format!("{}::{}", state.qualified_prefix(), name); |
| 752 | let id = generate_node_id(&state.file_path, &NodeKind::Constructor, &name, start_line); |
| 753 | let metrics = count_complexity(node, &JAVA_COMPLEXITY, &state.source); |
| 754 | |
| 755 | let graph_node = Node { |
| 756 | id: id.clone(), |
| 757 | kind: NodeKind::Constructor, |
| 758 | name, |
| 759 | qualified_name, |
| 760 | file_path: state.file_path.clone(), |
| 761 | start_line, |
| 762 | attrs_start_line: start_line, |
| 763 | end_line, |
| 764 | start_column, |
| 765 | end_column, |
| 766 | signature, |
| 767 | docstring, |
| 768 | visibility, |
| 769 | is_async: false, |
| 770 | branches: metrics.branches, |
| 771 | loops: metrics.loops, |
| 772 | returns: metrics.returns, |
| 773 | max_nesting: metrics.max_nesting, |
| 774 | unsafe_blocks: metrics.unsafe_blocks, |
| 775 | unchecked_calls: metrics.unchecked_calls, |
| 776 | assertions: metrics.assertions, |
| 777 | updated_at: state.timestamp, |
| 778 | parent_id: None, |
| 779 | }; |
| 780 | state.nodes.push(graph_node); |
| 781 | |
| 782 | // Contains edge from parent. |
| 783 | if let Some(parent_id) = state.parent_node_id() { |
| 784 | state.edges.push(Edge { |
| 785 | source: parent_id.to_string(), |
| 786 | target: id.clone(), |
| 787 | kind: EdgeKind::Contains, |
| 788 | line: Some(start_line), |
| 789 | }); |
| 790 | } |
| 791 | |
| 792 | // Extract type references from parameter types. |
| 793 | Self::extract_type_refs(state, node, &id); |
| 794 | |
| 795 | // Extract call sites from the constructor body. |
| 796 | Self::extract_call_sites(state, node, &id); |
| 797 | } |
| 798 | |
| 799 | /// Extract field declarations. Each `variable_declarator` in the field becomes a Field node. |
nothing calls this directly
no test coverage detected