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

Method visit_copy

src/extraction/dockerfile_extractor.rs:564–631  ·  view source on GitHub ↗

Extract COPY instruction, looking for `--from=STAGE` references. `COPY --from=builder ...` creates a Uses edge from the current stage (or file) to the referenced stage.

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

Source from the content-addressed store, hash-verified

562 /// `COPY --from=builder ...` creates a Uses edge from the current stage
563 /// (or file) to the referenced stage.
564 fn visit_copy(state: &mut ExtractionState, node: TsNode<'_>) {
565 let start_line = node.start_position().row as u32;
566
567 let mut cursor = node.walk();
568 if cursor.goto_first_child() {
569 loop {
570 let child = cursor.node();
571 if child.kind() == "param" {
572 let param_text = state.node_text(child);
573 if let Some(stage_name) = param_text.strip_prefix("--from=") {
574 let target = if let Some(target) = state.stage_target(stage_name) {
575 target
576 } else {
577 let id = generate_node_id(
578 &state.file_path,
579 &NodeKind::Use,
580 stage_name,
581 start_line,
582 );
583 let text = state.node_text(node);
584 state.nodes.push(Node {
585 id: id.clone(),
586 kind: NodeKind::Use,
587 name: stage_name.to_string(),
588 qualified_name: format!(
589 "{}::{}",
590 state.qualified_prefix(),
591 stage_name
592 ),
593 file_path: state.file_path.clone(),
594 start_line,
595 attrs_start_line: start_line,
596 end_line: node.end_position().row as u32,
597 start_column: node.start_position().column as u32,
598 end_column: node.end_position().column as u32,
599 signature: Some(text.trim().to_string()),
600 docstring: None,
601 visibility: Visibility::Pub,
602 is_async: false,
603 branches: 0,
604 loops: 0,
605 returns: 0,
606 max_nesting: 0,
607 unsafe_blocks: 0,
608 unchecked_calls: 0,
609 assertions: 0,
610 updated_at: state.timestamp,
611 parent_id: None,
612 });
613 id
614 };
615
616 if let Some(parent_id) = state.parent_node_id() {
617 state.edges.push(Edge {
618 source: parent_id.to_string(),
619 target,
620 kind: EdgeKind::Uses,
621 line: Some(start_line),

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected