── 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
| 877 | // → string_lit → template_literal). Descend through the expression/literal_value |
| 878 | // wrappers to reach the actual string token before reading it. |
| 879 | static 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 |
no test coverage detected