Emit a Use node for a `require` call.
(state: &mut ExtractionState, node: TsNode<'_>, mod_name: &str)
| 381 | |
| 382 | /// Emit a Use node for a `require` call. |
| 383 | fn emit_use_node(state: &mut ExtractionState, node: TsNode<'_>, mod_name: &str) { |
| 384 | let start_line = node.start_position().row as u32; |
| 385 | let end_line = node.end_position().row as u32; |
| 386 | let start_column = node.start_position().column as u32; |
| 387 | let end_column = node.end_position().column as u32; |
| 388 | let text = state.node_text(node); |
| 389 | let qualified_name = format!("{}::{}", state.qualified_prefix(), mod_name); |
| 390 | let id = generate_node_id(&state.file_path, &NodeKind::Use, mod_name, start_line); |
| 391 | |
| 392 | let graph_node = Node { |
| 393 | id: id.clone(), |
| 394 | kind: NodeKind::Use, |
| 395 | name: mod_name.to_string(), |
| 396 | qualified_name, |
| 397 | file_path: state.file_path.clone(), |
| 398 | start_line, |
| 399 | attrs_start_line: start_line, |
| 400 | end_line, |
| 401 | start_column, |
| 402 | end_column, |
| 403 | signature: Some(text.trim().to_string()), |
| 404 | docstring: None, |
| 405 | visibility: Visibility::Private, |
| 406 | is_async: false, |
| 407 | branches: 0, |
| 408 | loops: 0, |
| 409 | returns: 0, |
| 410 | max_nesting: 0, |
| 411 | unsafe_blocks: 0, |
| 412 | unchecked_calls: 0, |
| 413 | assertions: 0, |
| 414 | updated_at: state.timestamp, |
| 415 | parent_id: None, |
| 416 | }; |
| 417 | state.nodes.push(graph_node); |
| 418 | |
| 419 | // Contains edge from parent. |
| 420 | if let Some(parent_id) = state.parent_node_id() { |
| 421 | state.edges.push(Edge { |
| 422 | source: parent_id.to_string(), |
| 423 | target: id, |
| 424 | kind: EdgeKind::Contains, |
| 425 | line: Some(start_line), |
| 426 | }); |
| 427 | } |
| 428 | } |
| 429 | |
| 430 | /// Extract the module name from a `require("module")` call. |
| 431 | /// |
nothing calls this directly
no test coverage detected