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

Method visit_field

src/extraction/java_extractor.rs:800–873  ·  view source on GitHub ↗

Extract field declarations. Each `variable_declarator` in the field becomes a Field node.

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

Source from the content-addressed store, hash-verified

798
799 /// Extract field declarations. Each `variable_declarator` in the field becomes a Field node.
800 fn visit_field(state: &mut ExtractionState, node: TsNode<'_>) {
801 let visibility = Self::extract_java_visibility(node, state);
802 let start_line = node.start_position().row as u32;
803 let end_line = node.end_position().row as u32;
804 let start_column = node.start_position().column as u32;
805 let end_column = node.end_position().column as u32;
806 let signature_text = state.node_text(node).trim().to_string();
807
808 // Iterate over variable_declarator children to extract each field name.
809 let mut cursor = node.walk();
810 if cursor.goto_first_child() {
811 loop {
812 let child = cursor.node();
813 if child.kind() == "variable_declarator" {
814 // The variable_declarator contains an identifier as its "name" field.
815 let field_name = child.child_by_field_name("name").map_or_else(
816 || {
817 Self::extract_name(state, child)
818 .unwrap_or_else(|| "<anonymous>".to_string())
819 },
820 |n| state.node_text(n),
821 );
822
823 let qualified_name = format!("{}::{}", state.qualified_prefix(), field_name);
824 let id = generate_node_id(
825 &state.file_path,
826 &NodeKind::Field,
827 &field_name,
828 start_line,
829 );
830
831 let graph_node = Node {
832 id: id.clone(),
833 kind: NodeKind::Field,
834 name: field_name,
835 qualified_name,
836 file_path: state.file_path.clone(),
837 start_line,
838 attrs_start_line: start_line,
839 end_line,
840 start_column,
841 end_column,
842 signature: Some(signature_text.clone()),
843 docstring: None,
844 visibility: visibility.clone(),
845 is_async: false,
846 branches: 0,
847 loops: 0,
848 returns: 0,
849 max_nesting: 0,
850 unsafe_blocks: 0,
851 unchecked_calls: 0,
852 assertions: 0,
853 updated_at: state.timestamp,
854 parent_id: None,
855 };
856 state.nodes.push(graph_node);
857

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected