Process a keyword argument (keyword_argument or pair node).
| 2463 | |
| 2464 | // Process a keyword argument (keyword_argument or pair node). |
| 2465 | static void process_keyword_arg(CBMExtractCtx *ctx, TSNode arg_node, CBMCallArg *ca) { |
| 2466 | TSNode key_n = ts_node_child_by_field_name(arg_node, TS_FIELD("name")); |
| 2467 | TSNode val_n = ts_node_child_by_field_name(arg_node, TS_FIELD("value")); |
| 2468 | if (ts_node_is_null(key_n)) { |
| 2469 | key_n = ts_node_child_by_field_name(arg_node, TS_FIELD("key")); |
| 2470 | } |
| 2471 | if (!ts_node_is_null(key_n)) { |
| 2472 | ca->keyword = cbm_node_text(ctx->arena, key_n, ctx->source); |
| 2473 | } |
| 2474 | if (!ts_node_is_null(val_n)) { |
| 2475 | ca->expr = cbm_node_text(ctx->arena, val_n, ctx->source); |
| 2476 | /* Only a fully resolved fold is an exact value (#706, #1147). */ |
| 2477 | fold_call_arg(ctx, val_n, ca); |
| 2478 | if (ca->value || is_folded_reference(ctx, ts_node_type(val_n))) { |
| 2479 | return; |
| 2480 | } |
| 2481 | if (strcmp(ts_node_type(val_n), "identifier") == 0 && ca->expr) { |
| 2482 | ca->value = lookup_string_constant(ctx, ca->expr); |
| 2483 | } else if (is_string_like(ts_node_type(val_n)) && ca->expr) { |
| 2484 | ca->value = strip_quotes(ctx->arena, ca->expr); |
| 2485 | } |
| 2486 | } |
| 2487 | } |
| 2488 | |
| 2489 | static const char *extract_string_value(CBMExtractCtx *ctx, TSNode val_node, bool url_context); |
| 2490 |
no test coverage detected