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

Function fold_string_like

internal/cbm/extract_url_fold.c:182–200  ·  view source on GitHub ↗

JS/TS `string`, Python `string` (also f-strings), JS `template_string`. */

Source from the content-addressed store, hash-verified

180
181/* JS/TS `string`, Python `string` (also f-strings), JS `template_string`. */
182static const char *fold_string_like(CBMExtractCtx *ctx, TSNode node, int depth, bool url) {
183 fold_buf_t b = {.len = 0, .url = url};
184 b.text[0] = '\0';
185 uint32_t nc = ts_node_named_child_count(node);
186 for (uint32_t i = 0; i < nc; i++) {
187 TSNode c = ts_node_named_child(node, i);
188 const char *k = ts_node_type(c);
189 if (strcmp(k, "template_substitution") == 0 || strcmp(k, "interpolation") == 0) {
190 fold_part(ctx, &b, c, depth);
191 } else if (strcmp(k, "string_fragment") == 0 || strcmp(k, "string_content") == 0 ||
192 strcmp(k, "escape_sequence") == 0) {
193 fold_literal_piece(ctx, &b, c);
194 } else if (strcmp(k, "escape_interpolation") == 0) {
195 b.has_parts = true;
196 buf_append(&b, "{"); /* `{{` in an f-string is one literal brace */
197 }
198 }
199 return finish(ctx, &b);
200}
201
202static bool is_plus(CBMExtractCtx *ctx, TSNode bin) {
203 TSNode op = ts_node_child_by_field_name(bin, TS_FIELD("operator"));

Callers 2

fold_nodeFunction · 0.85
pair_keyFunction · 0.85

Calls 4

fold_partFunction · 0.85
fold_literal_pieceFunction · 0.85
buf_appendFunction · 0.85
finishFunction · 0.70

Tested by

no test coverage detected