(state: &mut ExtractionState, node: TsNode<'_>, is_macro: bool)
| 202 | } |
| 203 | |
| 204 | fn visit_defn(state: &mut ExtractionState, node: TsNode<'_>, is_macro: bool) { |
| 205 | // (defn name [args] "docstring" body) |
| 206 | let Some(name) = Self::nth_sym(state, node, 1) else { |
| 207 | return; |
| 208 | }; |
| 209 | let docstring = Self::extract_string_child(state, node); |
| 210 | let kind = if is_macro { |
| 211 | NodeKind::Macro |
| 212 | } else { |
| 213 | NodeKind::Function |
| 214 | }; |
| 215 | let start_line = node.start_position().row as u32; |
| 216 | let qualified_name = format!("{}::{}", state.qualified_prefix(), name); |
| 217 | let id = generate_node_id(&state.file_path, &kind, &name, start_line); |
| 218 | let sig = Self::first_line(state, node); |
| 219 | |
| 220 | let graph_node = Node { |
| 221 | id: id.clone(), |
| 222 | kind, |
| 223 | name, |
| 224 | qualified_name, |
| 225 | file_path: state.file_path.clone(), |
| 226 | start_line, |
| 227 | attrs_start_line: start_line, |
| 228 | end_line: node.end_position().row as u32, |
| 229 | start_column: node.start_position().column as u32, |
| 230 | end_column: node.end_position().column as u32, |
| 231 | signature: sig, |
| 232 | docstring, |
| 233 | visibility: Visibility::Pub, |
| 234 | is_async: false, |
| 235 | branches: 0, |
| 236 | loops: 0, |
| 237 | returns: 0, |
| 238 | max_nesting: 0, |
| 239 | unsafe_blocks: 0, |
| 240 | unchecked_calls: 0, |
| 241 | assertions: 0, |
| 242 | updated_at: state.timestamp, |
| 243 | parent_id: None, |
| 244 | }; |
| 245 | state.nodes.push(graph_node); |
| 246 | |
| 247 | if let Some(parent_id) = state.parent_node_id() { |
| 248 | state.edges.push(Edge { |
| 249 | source: parent_id.to_string(), |
| 250 | target: id.clone(), |
| 251 | kind: EdgeKind::Contains, |
| 252 | line: Some(start_line), |
| 253 | }); |
| 254 | } |
| 255 | |
| 256 | // Collect call sites from the body. |
| 257 | Self::extract_calls(state, node, &id, 2); |
| 258 | } |
| 259 | |
| 260 | fn visit_def(state: &mut ExtractionState, node: TsNode<'_>) { |
| 261 | // (def name value) |
nothing calls this directly
no test coverage detected