MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / visit_constructor

Method visit_constructor

src/extraction/csharp_extractor.rs:720–777  ·  view source on GitHub ↗

Extract a constructor declaration.

(state: &mut ExtractionState, node: TsNode<'_>)

Source from the content-addressed store, hash-verified

718
719 /// Extract a constructor declaration.
720 fn visit_constructor(state: &mut ExtractionState, node: TsNode<'_>) {
721 let name = Self::extract_name(state, node).unwrap_or_else(|| "<anonymous>".to_string());
722 let visibility = Self::extract_csharp_visibility(node, state);
723 let docstring = Self::extract_xml_docstring(state, node);
724 let signature = Some(Self::extract_declaration_signature(state, node));
725 let start_line = node.start_position().row as u32;
726 let end_line = node.end_position().row as u32;
727 let start_column = node.start_position().column as u32;
728 let end_column = node.end_position().column as u32;
729 let qualified_name = format!("{}::{}", state.qualified_prefix(), name);
730 let id = generate_node_id(&state.file_path, &NodeKind::Constructor, &name, start_line);
731 let metrics = count_complexity(node, &CSHARP_COMPLEXITY, &state.source);
732
733 let graph_node = Node {
734 id: id.clone(),
735 kind: NodeKind::Constructor,
736 name,
737 qualified_name,
738 file_path: state.file_path.clone(),
739 start_line,
740 attrs_start_line: start_line,
741 end_line,
742 start_column,
743 end_column,
744 signature,
745 docstring,
746 visibility,
747 is_async: false,
748 branches: metrics.branches,
749 loops: metrics.loops,
750 returns: metrics.returns,
751 max_nesting: metrics.max_nesting,
752 unsafe_blocks: metrics.unsafe_blocks,
753 unchecked_calls: metrics.unchecked_calls,
754 assertions: metrics.assertions,
755 updated_at: state.timestamp,
756 parent_id: None,
757 };
758 state.nodes.push(graph_node);
759
760 // Contains edge from parent.
761 if let Some(parent_id) = state.parent_node_id() {
762 state.edges.push(Edge {
763 source: parent_id.to_string(),
764 target: id.clone(),
765 kind: EdgeKind::Contains,
766 line: Some(start_line),
767 });
768 }
769
770 // Extract attributes on this constructor.
771 Self::extract_attributes_from_declaration(state, node, &id);
772
773 // Extract call sites from the constructor body.
774 if let Some(body) = node.child_by_field_name("body") {
775 Self::extract_call_sites(state, body, &id);
776 }
777 }

Callers

nothing calls this directly

Calls 4

generate_node_idFunction · 0.85
count_complexityFunction · 0.85
pushMethod · 0.80
parent_node_idMethod · 0.45

Tested by

no test coverage detected