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

Function kt_bind_function_params

internal/cbm/lsp/kotlin_lsp.c:3225–3272  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3223}
3224
3225static void kt_bind_function_params(KotlinLSPContext *ctx, TSNode func_node) {
3226 TSNode params = kt_field_named(func_node, "parameters");
3227 if (ts_node_is_null(params)) {
3228 params = kt_child_kind(func_node, "function_value_parameters");
3229 }
3230 if (ts_node_is_null(params)) {
3231 return;
3232 }
3233 uint32_t nc = ts_node_named_child_count(params);
3234 for (uint32_t i = 0; i < nc; i++) {
3235 TSNode p = ts_node_named_child(params, i);
3236 if (!kt_node_is(p, "parameter") && !kt_node_is(p, "_lambda_parameter")) {
3237 continue;
3238 }
3239 TSNode name = kt_field_named(p, "name");
3240 if (ts_node_is_null(name)) {
3241 name = kt_name_child(p);
3242 }
3243 if (ts_node_is_null(name)) {
3244 name = kt_child_kind_named(p, "simple_identifier");
3245 }
3246 if (ts_node_is_null(name)) {
3247 continue;
3248 }
3249 char *pname = kt_node_text(ctx, name);
3250 if (!pname) {
3251 continue;
3252 }
3253 TSNode type_node = kt_field_named(p, "type");
3254 if (ts_node_is_null(type_node)) {
3255 type_node = kt_child_kind(p, "type");
3256 }
3257 if (ts_node_is_null(type_node)) {
3258 type_node = kt_child_kind(p, "user_type");
3259 }
3260 if (ts_node_is_null(type_node)) {
3261 type_node = kt_child_kind(p, "nullable_type");
3262 }
3263 const CBMType *t = ts_node_is_null(type_node) ? cbm_type_unknown()
3264 : kotlin_parse_type_node(ctx, type_node);
3265 cbm_scope_bind(ctx->current_scope, cbm_arena_strdup(ctx->arena, pname), t);
3266 }
3267
3268 /* For extension fun and method: bind `this` */
3269 if (ctx->this_type) {
3270 cbm_scope_bind(ctx->current_scope, "this", ctx->this_type);
3271 }
3272}
3273
3274/* ── top-level walking ────────────────────────────────────────────── */
3275

Callers 3

kt_process_statementFunction · 0.85
kt_process_function_bodyFunction · 0.85

Calls 10

kt_field_namedFunction · 0.85
kt_child_kindFunction · 0.85
kt_node_isFunction · 0.85
kt_name_childFunction · 0.85
kt_child_kind_namedFunction · 0.85
kt_node_textFunction · 0.85
cbm_type_unknownFunction · 0.85
kotlin_parse_type_nodeFunction · 0.85
cbm_scope_bindFunction · 0.85
cbm_arena_strdupFunction · 0.50

Tested by

no test coverage detected