(state: &mut ExtractionState, node: TsNode<'_>)
| 141 | } |
| 142 | |
| 143 | fn visit_function_or_value(state: &mut ExtractionState, node: TsNode<'_>) { |
| 144 | // function_or_value_defn contains function_declaration_left or value_declaration_left. |
| 145 | let name = Self::extract_binding_name(state, node); |
| 146 | let Some(name) = name else { return }; |
| 147 | |
| 148 | let is_fn = Self::has_params(node); |
| 149 | let kind = if is_fn { |
| 150 | NodeKind::Function |
| 151 | } else { |
| 152 | NodeKind::Const |
| 153 | }; |
| 154 | let sig = Self::first_line(state, node); |
| 155 | let docstring = Self::extract_docstring(state, node); |
| 156 | let start_line = node.start_position().row as u32; |
| 157 | let qualified_name = format!("{}::{}", state.qualified_prefix(), name); |
| 158 | let id = generate_node_id(&state.file_path, &kind, &name, start_line); |
| 159 | |
| 160 | let metrics = if is_fn && node.child_count() > 0 { |
| 161 | count_complexity(node, &FSHARP_COMPLEXITY, &state.source) |
| 162 | } else { |
| 163 | ComplexityMetrics::default() |
| 164 | }; |
| 165 | |
| 166 | let graph_node = Node { |
| 167 | id: id.clone(), |
| 168 | kind, |
| 169 | name: name.clone(), |
| 170 | qualified_name, |
| 171 | file_path: state.file_path.clone(), |
| 172 | start_line, |
| 173 | attrs_start_line: start_line, |
| 174 | end_line: node.end_position().row as u32, |
| 175 | start_column: node.start_position().column as u32, |
| 176 | end_column: node.end_position().column as u32, |
| 177 | signature: sig, |
| 178 | docstring, |
| 179 | visibility: Visibility::Pub, |
| 180 | is_async: false, |
| 181 | branches: metrics.branches, |
| 182 | loops: metrics.loops, |
| 183 | returns: metrics.returns, |
| 184 | max_nesting: metrics.max_nesting, |
| 185 | unsafe_blocks: 0, |
| 186 | unchecked_calls: metrics.unchecked_calls, |
| 187 | assertions: metrics.assertions, |
| 188 | updated_at: state.timestamp, |
| 189 | parent_id: None, |
| 190 | }; |
| 191 | state.nodes.push(graph_node); |
| 192 | |
| 193 | if let Some(parent_id) = state.parent_node_id() { |
| 194 | state.edges.push(Edge { |
| 195 | source: parent_id.to_string(), |
| 196 | target: id.clone(), |
| 197 | kind: EdgeKind::Contains, |
| 198 | line: Some(start_line), |
| 199 | }); |
| 200 | } |
nothing calls this directly
no test coverage detected