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

Method create_use_node

src/extraction/php_extractor.rs:737–791  ·  view source on GitHub ↗

Create a Use node for a PHP use/import declaration.

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

Source from the content-addressed store, hash-verified

735
736 /// Create a Use node for a PHP use/import declaration.
737 fn create_use_node(state: &mut ExtractionState, name: &str, node: TsNode<'_>) {
738 let start_line = node.start_position().row as u32;
739 let end_line = node.end_position().row as u32;
740 let start_column = node.start_position().column as u32;
741 let end_column = node.end_position().column as u32;
742 let qualified_name = format!("{}::{}", state.qualified_prefix(), name);
743 let id = generate_node_id(&state.file_path, &NodeKind::Use, name, start_line);
744
745 let graph_node = Node {
746 id: id.clone(),
747 kind: NodeKind::Use,
748 name: name.to_string(),
749 qualified_name,
750 file_path: state.file_path.clone(),
751 start_line,
752 attrs_start_line: start_line,
753 end_line,
754 start_column,
755 end_column,
756 signature: Some(state.node_text(node).trim().to_string()),
757 docstring: None,
758 visibility: Visibility::Private,
759 is_async: false,
760 branches: 0,
761 loops: 0,
762 returns: 0,
763 max_nesting: 0,
764 unsafe_blocks: 0,
765 unchecked_calls: 0,
766 assertions: 0,
767 updated_at: state.timestamp,
768 parent_id: None,
769 };
770 state.nodes.push(graph_node);
771
772 // Contains edge from parent.
773 if let Some(parent_id) = state.parent_node_id() {
774 state.edges.push(Edge {
775 source: parent_id.to_string(),
776 target: id.clone(),
777 kind: EdgeKind::Contains,
778 line: Some(start_line),
779 });
780 }
781
782 // Unresolved Uses reference.
783 state.unresolved_refs.push(UnresolvedRef {
784 from_node_id: id,
785 reference_name: name.to_string(),
786 reference_kind: EdgeKind::Uses,
787 line: start_line,
788 column: start_column,
789 file_path: state.file_path.clone(),
790 });
791 }
792
793 /// Extract a const declaration (can be at file level or inside a class).
794 fn visit_const_declaration(state: &mut ExtractionState, node: TsNode<'_>) {

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