JS/TS `string`, Python `string` (also f-strings), JS `template_string`. */
| 180 | |
| 181 | /* JS/TS `string`, Python `string` (also f-strings), JS `template_string`. */ |
| 182 | static 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 | |
| 202 | static bool is_plus(CBMExtractCtx *ctx, TSNode bin) { |
| 203 | TSNode op = ts_node_child_by_field_name(bin, TS_FIELD("operator")); |
no test coverage detected