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

Function scan_nested_mapping_targets

internal/cbm/extract_unified.c:1725–1754  ·  view source on GitHub ↗

Scan a nested YAML block_mapping for target keys (push_endpoint, uri, etc.).

Source from the content-addressed store, hash-verified

1723
1724// Scan a nested YAML block_mapping for target keys (push_endpoint, uri, etc.).
1725static void scan_nested_mapping_targets(CBMExtractCtx *ctx, TSNode val, const char **targets,
1726 int *n_targets) {
1727 uint32_t vnc = ts_node_named_child_count(val);
1728 for (uint32_t vi = 0; vi < vnc; vi++) {
1729 TSNode vc = ts_node_named_child(val, vi);
1730 if (strcmp(ts_node_type(vc), "block_mapping") != 0) {
1731 continue;
1732 }
1733 uint32_t mnc = ts_node_named_child_count(vc);
1734 for (uint32_t mi = 0; mi < mnc; mi++) {
1735 TSNode mp = ts_node_named_child(vc, mi);
1736 if (strcmp(ts_node_type(mp), "block_mapping_pair") != 0) {
1737 continue;
1738 }
1739 TSNode mk = ts_node_child_by_field_name(mp, TS_FIELD("key"));
1740 TSNode mv = ts_node_child_by_field_name(mp, TS_FIELD("value"));
1741 if (ts_node_is_null(mk) || ts_node_is_null(mv)) {
1742 continue;
1743 }
1744 char *mktext = cbm_node_text(ctx->arena, mk, ctx->source);
1745 if (mktext && is_target_key(mktext) && *n_targets < MAX_INFRA_BINDINGS) {
1746 char *mvtext =
1747 strip_yaml_quotes(ctx->arena, cbm_node_text(ctx->arena, mv, ctx->source));
1748 if (mvtext && strstr(mvtext, "://")) {
1749 targets[(*n_targets)++] = mvtext;
1750 }
1751 }
1752 }
1753 }
1754}
1755
1756// Emit infra bindings for each source × target pair combination.
1757static void emit_infra_bindings(CBMExtractCtx *ctx, const char **sources, const char **source_keys,

Callers 1

Calls 3

cbm_node_textFunction · 0.85
is_target_keyFunction · 0.85
strip_yaml_quotesFunction · 0.85

Tested by

no test coverage detected