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

Method visit_field

src/extraction/zig_extractor.rs:593–642  ·  view source on GitHub ↗

Extract a field from a `container_field` inside a struct.

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

Source from the content-addressed store, hash-verified

591
592 /// Extract a field from a `container_field` inside a struct.
593 fn visit_field(state: &mut ExtractionState, node: TsNode<'_>) {
594 let name = node
595 .child_by_field_name("name")
596 .map_or_else(|| "<anonymous>".to_string(), |n| state.node_text(n));
597
598 let docstring = Self::extract_docstring(state, node);
599 let start_line = node.start_position().row as u32;
600 let end_line = node.end_position().row as u32;
601 let start_column = node.start_position().column as u32;
602 let end_column = node.end_position().column as u32;
603 let qualified_name = format!("{}::{}", state.qualified_prefix(), name);
604 let id = generate_node_id(&state.file_path, &NodeKind::Field, &name, start_line);
605
606 let graph_node = Node {
607 id: id.clone(),
608 kind: NodeKind::Field,
609 name,
610 qualified_name,
611 file_path: state.file_path.clone(),
612 start_line,
613 attrs_start_line: start_line,
614 end_line,
615 start_column,
616 end_column,
617 signature: Some(state.node_text(node).trim().to_string()),
618 docstring,
619 visibility: Visibility::Pub,
620 is_async: false,
621 branches: 0,
622 loops: 0,
623 returns: 0,
624 max_nesting: 0,
625 unsafe_blocks: 0,
626 unchecked_calls: 0,
627 assertions: 0,
628 updated_at: state.timestamp,
629 parent_id: None,
630 };
631 state.nodes.push(graph_node);
632
633 // Contains edge from parent (struct).
634 if let Some(parent_id) = state.parent_node_id() {
635 state.edges.push(Edge {
636 source: parent_id.to_string(),
637 target: id,
638 kind: EdgeKind::Contains,
639 line: Some(start_line),
640 });
641 }
642 }
643
644 // ----------------------------------
645 // Function / Method

Callers

nothing calls this directly

Calls 4

generate_node_idFunction · 0.85
pushMethod · 0.80
node_textMethod · 0.45
parent_node_idMethod · 0.45

Tested by

no test coverage detected