MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / resolve_field_name_node

Function resolve_field_name_node

internal/cbm/extract_defs.c:10630–10658  ·  view source on GitHub ↗

Resolve the name node for a field declaration, unwrapping C pointer/array declarators.

Source from the content-addressed store, hash-verified

10628
10629// Resolve the name node for a field declaration, unwrapping C pointer/array declarators.
10630static TSNode resolve_field_name_node(TSNode child) {
10631 TSNode name_node = ts_node_child_by_field_name(child, TS_FIELD("declarator"));
10632 if (ts_node_is_null(name_node)) {
10633 name_node = ts_node_child_by_field_name(child, TS_FIELD("name"));
10634 }
10635 if (ts_node_is_null(name_node)) {
10636 TSNode null_node = {0};
10637 return null_node;
10638 }
10639 const char *nk = ts_node_type(name_node);
10640 /* Java `private static final String PROP = "v";`: the declarator holds the
10641 * initializer too, so its text named the Field `PROP = "v"`; its name is
10642 * the declarator's own name field */
10643 if (strcmp(nk, "variable_declarator") == 0) {
10644 TSNode inner = ts_node_child_by_field_name(name_node, TS_FIELD("name"));
10645 if (!ts_node_is_null(inner)) {
10646 return inner;
10647 }
10648 }
10649 if (strcmp(nk, "pointer_declarator") == 0 || strcmp(nk, "array_declarator") == 0) {
10650 TSNode inner = ts_node_child_by_field_name(name_node, TS_FIELD("declarator"));
10651 if (!ts_node_is_null(inner)) {
10652 return inner;
10653 }
10654 TSNode null_node = {0};
10655 return null_node;
10656 }
10657 return name_node;
10658}
10659
10660/* Schema/grammar languages whose field node carries the field name on a plain
10661 * child (no C-style `declarator`/`type` field), so the generic field path below

Callers 1

extract_class_fieldsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected