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

Function find_xml_element_name

internal/cbm/extract_defs.c:7068–7091  ·  view source on GitHub ↗

Extract XML element name from start_tag/self_closing_tag children.

Source from the content-addressed store, hash-verified

7066
7067// Extract XML element name from start_tag/self_closing_tag children.
7068static char *find_xml_element_name(CBMArena *a, TSNode node, const char *source) {
7069 uint32_t nc = ts_node_child_count(node);
7070 for (uint32_t i = 0; i < nc; i++) {
7071 TSNode child = ts_node_child(node, i);
7072 const char *ck = ts_node_type(child);
7073 if (strcmp(ck, "start_tag") == 0 || strcmp(ck, "self_closing_tag") == 0 ||
7074 strcmp(ck, "STag") == 0 || strcmp(ck, "EmptyElemTag") == 0) {
7075 uint32_t tnc = ts_node_child_count(child);
7076 for (uint32_t j = 0; j < tnc; j++) {
7077 TSNode tag = ts_node_child(child, j);
7078 const char *tk = ts_node_type(tag);
7079 if (strcmp(tk, "tag_name") == 0 || strcmp(tk, "Name") == 0) {
7080 return cbm_node_text(a, tag, source);
7081 }
7082 }
7083 }
7084 }
7085 // Fallback: try "Name" field directly for some XML grammars
7086 TSNode name_child = cbm_find_child_by_kind(node, "Name");
7087 if (!ts_node_is_null(name_child)) {
7088 return cbm_node_text(a, name_child, source);
7089 }
7090 return NULL;
7091}
7092
7093// Extract text from an atx_heading node (# Title).
7094static char *extract_atx_heading_text(CBMArena *a, TSNode node, const char *source) {

Callers 1

extract_config_class_defFunction · 0.85

Calls 2

cbm_node_textFunction · 0.85
cbm_find_child_by_kindFunction · 0.85

Tested by

no test coverage detected