Extract a method declaration.
(state: &mut ExtractionState, node: TsNode<'_>)
| 648 | |
| 649 | /// Extract a method declaration. |
| 650 | fn visit_method(state: &mut ExtractionState, node: TsNode<'_>) { |
| 651 | let name = Self::extract_name(state, node).unwrap_or_else(|| "<anonymous>".to_string()); |
| 652 | let visibility = Self::extract_csharp_visibility(node, state); |
| 653 | let docstring = Self::extract_xml_docstring(state, node); |
| 654 | let signature = Some(Self::extract_declaration_signature(state, node)); |
| 655 | let start_line = node.start_position().row as u32; |
| 656 | let end_line = node.end_position().row as u32; |
| 657 | let start_column = node.start_position().column as u32; |
| 658 | let end_column = node.end_position().column as u32; |
| 659 | let qualified_name = format!("{}::{}", state.qualified_prefix(), name); |
| 660 | |
| 661 | let is_async = Self::has_modifier(node, state, "async"); |
| 662 | |
| 663 | // If inside a class/struct, it's a Method; otherwise Function |
| 664 | let kind = if state.class_depth > 0 { |
| 665 | NodeKind::Method |
| 666 | } else { |
| 667 | NodeKind::Function |
| 668 | }; |
| 669 | |
| 670 | let id = generate_node_id(&state.file_path, &kind, &name, start_line); |
| 671 | let metrics = count_complexity(node, &CSHARP_COMPLEXITY, &state.source); |
| 672 | |
| 673 | let graph_node = Node { |
| 674 | id: id.clone(), |
| 675 | kind, |
| 676 | name: name.clone(), |
| 677 | qualified_name, |
| 678 | file_path: state.file_path.clone(), |
| 679 | start_line, |
| 680 | attrs_start_line: start_line, |
| 681 | end_line, |
| 682 | start_column, |
| 683 | end_column, |
| 684 | signature, |
| 685 | docstring, |
| 686 | visibility, |
| 687 | is_async, |
| 688 | branches: metrics.branches, |
| 689 | loops: metrics.loops, |
| 690 | returns: metrics.returns, |
| 691 | max_nesting: metrics.max_nesting, |
| 692 | unsafe_blocks: metrics.unsafe_blocks, |
| 693 | unchecked_calls: metrics.unchecked_calls, |
| 694 | assertions: metrics.assertions, |
| 695 | updated_at: state.timestamp, |
| 696 | parent_id: None, |
| 697 | }; |
| 698 | state.nodes.push(graph_node); |
| 699 | |
| 700 | // Contains edge from parent. |
| 701 | if let Some(parent_id) = state.parent_node_id() { |
| 702 | state.edges.push(Edge { |
| 703 | source: parent_id.to_string(), |
| 704 | target: id.clone(), |
| 705 | kind: EdgeKind::Contains, |
| 706 | line: Some(start_line), |
| 707 | }); |
nothing calls this directly
no test coverage detected