Visit a FUNCTION...END FUNCTION definition and emit a Function node.
(
state: &mut ExtractionState,
node: TsNode<'_>,
pending_comment: Option<&str>,
)
| 550 | |
| 551 | /// Visit a FUNCTION...END FUNCTION definition and emit a Function node. |
| 552 | fn visit_function_definition( |
| 553 | state: &mut ExtractionState, |
| 554 | node: TsNode<'_>, |
| 555 | pending_comment: Option<&str>, |
| 556 | ) { |
| 557 | let Some(name_node) = node.child_by_field_name("name") else { |
| 558 | return; |
| 559 | }; |
| 560 | let name = state.node_text(name_node); |
| 561 | |
| 562 | let start_line = node.start_position().row as u32; |
| 563 | let end_line = node.end_position().row as u32; |
| 564 | let start_column = node.start_position().column as u32; |
| 565 | let end_column = node.end_position().column as u32; |
| 566 | let qualified_name = format!("{}::{}", state.qualified_prefix(), name); |
| 567 | let fn_id = generate_node_id(&state.file_path, &NodeKind::Function, &name, start_line); |
| 568 | |
| 569 | let text = state.node_text(node); |
| 570 | let signature = text.lines().next().unwrap_or("").trim().to_string(); |
| 571 | |
| 572 | let metrics = if node.child_count() > 0 { |
| 573 | count_complexity(node, &QBASIC_COMPLEXITY, &state.source) |
| 574 | } else { |
| 575 | ComplexityMetrics::default() |
| 576 | }; |
| 577 | |
| 578 | let graph_node = Node { |
| 579 | id: fn_id.clone(), |
| 580 | kind: NodeKind::Function, |
| 581 | name: name.clone(), |
| 582 | qualified_name, |
| 583 | file_path: state.file_path.clone(), |
| 584 | start_line, |
| 585 | attrs_start_line: start_line, |
| 586 | end_line, |
| 587 | start_column, |
| 588 | end_column, |
| 589 | signature: Some(signature), |
| 590 | docstring: pending_comment.map(std::string::ToString::to_string), |
| 591 | visibility: Visibility::Pub, |
| 592 | is_async: false, |
| 593 | branches: metrics.branches, |
| 594 | loops: metrics.loops, |
| 595 | returns: metrics.returns, |
| 596 | max_nesting: metrics.max_nesting, |
| 597 | unsafe_blocks: metrics.unsafe_blocks, |
| 598 | unchecked_calls: metrics.unchecked_calls, |
| 599 | assertions: metrics.assertions, |
| 600 | updated_at: state.timestamp, |
| 601 | parent_id: None, |
| 602 | }; |
| 603 | state.nodes.push(graph_node); |
| 604 | |
| 605 | if let Some(parent_id) = state.parent_node_id() { |
| 606 | state.edges.push(Edge { |
| 607 | source: parent_id.to_string(), |
| 608 | target: fn_id.clone(), |
| 609 | kind: EdgeKind::Contains, |
nothing calls this directly
no test coverage detected