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

Function extract_hcl_string_val

internal/cbm/extract_unified.c:879–898  ·  view source on GitHub ↗

── HCL infrastructure binding extraction ─────────────────────────── * Scan HCL block nodes (resource, dynamic) for attribute pairs * where one is a source key (topic, queue_name) and another is a * target key (uri, push_endpoint). Handles nested blocks like * push_config { push_endpoint = "..." }. */ Extract a string value from an HCL attribute value node. The tree-sitter-hcl grammar wraps t

Source from the content-addressed store, hash-verified

877// → string_lit → template_literal). Descend through the expression/literal_value
878// wrappers to reach the actual string token before reading it.
879static char *extract_hcl_string_val(CBMArena *a, TSNode val_node, const char *source) {
880 enum { HCL_MAX_UNWRAP = 5 };
881 for (int depth = 0; depth < HCL_MAX_UNWRAP; depth++) {
882 const char *vk = ts_node_type(val_node);
883 if (strcmp(vk, "expression") == 0 || strcmp(vk, "literal_value") == 0) {
884 if (ts_node_named_child_count(val_node) == 0) {
885 return NULL;
886 }
887 val_node = ts_node_named_child(val_node, 0);
888 continue;
889 }
890 if (strcmp(vk, "quoted_template") == 0 || strcmp(vk, "template_literal") == 0 ||
891 strcmp(vk, "string_lit") == 0) {
892 char *val = cbm_node_text(a, val_node, source);
893 return strip_yaml_quotes(a, val);
894 }
895 return NULL;
896 }
897 return NULL;
898}
899
900// The tree-sitter-hcl grammar nests a block's attributes/sub-blocks inside a
901// `body` child rather than directly under the block. Return that body node so

Callers 2

Calls 2

cbm_node_textFunction · 0.85
strip_yaml_quotesFunction · 0.85

Tested by

no test coverage detected