(state: &mut ExtractionState, node: TsNode<'_>)
| 161 | } |
| 162 | |
| 163 | fn visit_let_binding(state: &mut ExtractionState, node: TsNode<'_>) { |
| 164 | let Some(pattern) = node.child_by_field_name("pattern") else { |
| 165 | return; |
| 166 | }; |
| 167 | |
| 168 | let name = Self::extract_value_name(state, pattern); |
| 169 | let Some(name) = name else { return }; |
| 170 | |
| 171 | // Determine if it's a function (has parameters or a fun-shaped body). |
| 172 | let is_fn = node.child_by_field_name("parameters").is_some() |
| 173 | || node |
| 174 | .child_by_field_name("body") |
| 175 | .is_some_and(|b| matches!(b.kind(), "fun_expression" | "function_expression")); |
| 176 | |
| 177 | let kind = if is_fn { |
| 178 | NodeKind::Function |
| 179 | } else { |
| 180 | NodeKind::Const |
| 181 | }; |
| 182 | let docstring = Self::extract_docstring(state, node); |
| 183 | let sig = Self::first_line(state, node); |
| 184 | let start_line = node.start_position().row as u32; |
| 185 | let qualified_name = format!("{}::{}", state.qualified_prefix(), name); |
| 186 | let id = generate_node_id(&state.file_path, &kind, &name, start_line); |
| 187 | |
| 188 | let metrics = if is_fn && node.child_count() > 0 { |
| 189 | count_complexity(node, &OCAML_COMPLEXITY, &state.source) |
| 190 | } else { |
| 191 | ComplexityMetrics::default() |
| 192 | }; |
| 193 | |
| 194 | let graph_node = Node { |
| 195 | id: id.clone(), |
| 196 | kind, |
| 197 | name: name.clone(), |
| 198 | qualified_name, |
| 199 | file_path: state.file_path.clone(), |
| 200 | start_line, |
| 201 | attrs_start_line: start_line, |
| 202 | end_line: node.end_position().row as u32, |
| 203 | start_column: node.start_position().column as u32, |
| 204 | end_column: node.end_position().column as u32, |
| 205 | signature: sig, |
| 206 | docstring, |
| 207 | visibility: Visibility::Pub, |
| 208 | is_async: false, |
| 209 | branches: metrics.branches, |
| 210 | loops: metrics.loops, |
| 211 | returns: metrics.returns, |
| 212 | max_nesting: metrics.max_nesting, |
| 213 | unsafe_blocks: 0, |
| 214 | unchecked_calls: metrics.unchecked_calls, |
| 215 | assertions: metrics.assertions, |
| 216 | updated_at: state.timestamp, |
| 217 | parent_id: None, |
| 218 | }; |
| 219 | state.nodes.push(graph_node); |
| 220 |
nothing calls this directly
no test coverage detected