Annotation text of the __init__ parameter called `name`, or NULL. */
| 7341 | |
| 7342 | /* Annotation text of the __init__ parameter called `name`, or NULL. */ |
| 7343 | static const char *py_init_param_annotation(CBMExtractCtx *ctx, TSNode params, const char *name) { |
| 7344 | uint32_t n = ts_node_named_child_count(params); |
| 7345 | for (uint32_t i = 0; i < n; i++) { |
| 7346 | TSNode p = ts_node_named_child(params, i); |
| 7347 | const char *pk = ts_node_type(p); |
| 7348 | TSNode pname = {0}; |
| 7349 | if (strcmp(pk, "typed_default_parameter") == 0) { |
| 7350 | pname = ts_node_child_by_field_name(p, TS_FIELD("name")); |
| 7351 | } else if (strcmp(pk, "typed_parameter") == 0 && ts_node_named_child_count(p) > 0) { |
| 7352 | pname = ts_node_named_child(p, 0); |
| 7353 | } else { |
| 7354 | continue; |
| 7355 | } |
| 7356 | TSNode ptype = ts_node_child_by_field_name(p, TS_FIELD("type")); |
| 7357 | if (ts_node_is_null(pname) || ts_node_is_null(ptype) || |
| 7358 | strcmp(ts_node_type(pname), "identifier") != 0) { |
| 7359 | continue; |
| 7360 | } |
| 7361 | char *pn = cbm_node_text(ctx->arena, pname, ctx->source); |
| 7362 | if (pn && strcmp(pn, name) == 0) { |
| 7363 | return cbm_node_text(ctx->arena, ptype, ctx->source); |
| 7364 | } |
| 7365 | } |
| 7366 | return NULL; |
| 7367 | } |
| 7368 | |
| 7369 | /* `self.x: T = v` / `self.x = p` inside __init__ (self = its first parameter). */ |
| 7370 | static void py_init_field_assignment(CBMExtractCtx *ctx, const char *class_qn, TSNode assign, |
no test coverage detected