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

Method visit_const

src/extraction/zig_extractor.rs:540–586  ·  view source on GitHub ↗

Extract a plain constant: `const max_connections: u32 = 100`.

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

Source from the content-addressed store, hash-verified

538
539 /// Extract a plain constant: `const max_connections: u32 = 100`.
540 fn visit_const(state: &mut ExtractionState, node: TsNode<'_>, name: &str) {
541 let docstring = Self::extract_docstring(state, node);
542 let start_line = node.start_position().row as u32;
543 let end_line = node.end_position().row as u32;
544 let start_column = node.start_position().column as u32;
545 let end_column = node.end_position().column as u32;
546 let text = state.node_text(node);
547 let qualified_name = format!("{}::{}", state.qualified_prefix(), name);
548 let id = generate_node_id(&state.file_path, &NodeKind::Const, name, start_line);
549
550 let graph_node = Node {
551 id: id.clone(),
552 kind: NodeKind::Const,
553 name: name.to_string(),
554 qualified_name,
555 file_path: state.file_path.clone(),
556 start_line,
557 attrs_start_line: start_line,
558 end_line,
559 start_column,
560 end_column,
561 signature: Some(text.trim().to_string()),
562 docstring,
563 visibility: Visibility::Private,
564 is_async: false,
565 branches: 0,
566 loops: 0,
567 returns: 0,
568 max_nesting: 0,
569 unsafe_blocks: 0,
570 unchecked_calls: 0,
571 assertions: 0,
572 updated_at: state.timestamp,
573 parent_id: None,
574 };
575 state.nodes.push(graph_node);
576
577 // Contains edge from parent.
578 if let Some(parent_id) = state.parent_node_id() {
579 state.edges.push(Edge {
580 source: parent_id.to_string(),
581 target: id,
582 kind: EdgeKind::Contains,
583 line: Some(start_line),
584 });
585 }
586 }
587
588 // ----------------------------------
589 // Field

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