Extract string value from a node (literal or constant reference).
| 2667 | |
| 2668 | // Extract string value from a node (literal or constant reference). |
| 2669 | static const char *extract_string_value(CBMExtractCtx *ctx, TSNode val_node, bool url_context) { |
| 2670 | const char *vk = ts_node_type(val_node); |
| 2671 | const char *folded = |
| 2672 | url_context ? cbm_url_fold_call_url(ctx, val_node) : cbm_url_fold_call_raw(ctx, val_node); |
| 2673 | if (folded || is_folded_reference(ctx, vk)) { |
| 2674 | return folded; |
| 2675 | } |
| 2676 | if (strcmp(vk, "template_string") == 0) { |
| 2677 | return cbm_template_string_text(ctx->arena, val_node, ctx->source); |
| 2678 | } |
| 2679 | if (is_string_like(vk)) { |
| 2680 | char *text = cbm_node_text(ctx->arena, val_node, ctx->source); |
| 2681 | if (text && text[0]) { |
| 2682 | return strip_quotes(ctx->arena, text); |
| 2683 | } |
| 2684 | } else if (strcmp(vk, "identifier") == 0) { |
| 2685 | char *const_name = cbm_node_text(ctx->arena, val_node, ctx->source); |
| 2686 | if (const_name) { |
| 2687 | return lookup_string_constant(ctx, const_name); |
| 2688 | } |
| 2689 | } |
| 2690 | return NULL; |
| 2691 | } |
| 2692 | |
| 2693 | // Recover a queue/topic identity from a Go composite-literal input struct, e.g. |
| 2694 | // &sqs.SendMessageInput{QueueUrl: queueUrl, MessageBody: body} |
no test coverage detected