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

Method extract_variable_declarators

src/extraction/csharp_extractor.rs:862–948  ·  view source on GitHub ↗

Extract variable declarators from a `variable_declaration` node.

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

Source from the content-addressed store, hash-verified

860
861 /// Extract variable declarators from a `variable_declaration` node.
862 fn extract_variable_declarators(
863 state: &mut ExtractionState,
864 node: TsNode<'_>,
865 visibility: &Visibility,
866 field_decl: TsNode<'_>,
867 ) {
868 let start_line = field_decl.start_position().row as u32;
869 let end_line = field_decl.end_position().row as u32;
870 let start_column = field_decl.start_position().column as u32;
871 let end_column = field_decl.end_position().column as u32;
872 let signature_text = state.node_text(field_decl).trim().to_string();
873 let mut cursor = node.walk();
874 if cursor.goto_first_child() {
875 loop {
876 let child = cursor.node();
877 if child.kind() == "variable_declarator" {
878 let field_name = child
879 .child_by_field_name("name")
880 .or_else(|| {
881 // Try direct identifier child
882 let mut inner = child.walk();
883 if inner.goto_first_child() {
884 loop {
885 let ic = inner.node();
886 if ic.kind() == "identifier" {
887 return Some(ic);
888 }
889 if !inner.goto_next_sibling() {
890 break;
891 }
892 }
893 }
894 None
895 })
896 .map_or_else(|| state.node_text(child), |n| state.node_text(n));
897
898 let qualified_name = format!("{}::{}", state.qualified_prefix(), field_name);
899 let id = generate_node_id(
900 &state.file_path,
901 &NodeKind::Field,
902 &field_name,
903 start_line,
904 );
905
906 let graph_node = Node {
907 id: id.clone(),
908 kind: NodeKind::Field,
909 name: field_name,
910 qualified_name,
911 file_path: state.file_path.clone(),
912 start_line,
913 attrs_start_line: start_line,
914 end_line,
915 start_column,
916 end_column,
917 signature: Some(signature_text.clone()),
918 docstring: None,
919 visibility: visibility.clone(),

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