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

Function cs_process_function_like

internal/cbm/lsp/cs_lsp.c:2462–2623  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2460}
2461
2462static void cs_process_function_like(CSLSPContext *ctx, TSNode node) {
2463 const char *kind = ts_node_type(node);
2464 bool is_method =
2465 (strcmp(kind, "method_declaration") == 0 || strcmp(kind, "local_function_statement") == 0);
2466 bool is_ctor = strcmp(kind, "constructor_declaration") == 0;
2467 bool is_dtor = strcmp(kind, "destructor_declaration") == 0;
2468 bool is_property = strcmp(kind, "property_declaration") == 0;
2469 bool is_indexer = strcmp(kind, "indexer_declaration") == 0;
2470 bool is_op = strcmp(kind, "operator_declaration") == 0 ||
2471 strcmp(kind, "conversion_operator_declaration") == 0;
2472
2473 CBMScope *saved_scope = ctx->current_scope;
2474 const char *saved_func = ctx->enclosing_func_qn;
2475 const char **saved_tp = ctx->type_param_names;
2476 const CBMType **saved_tp_args = ctx->type_param_args;
2477 int saved_tp_count = ctx->type_param_count;
2478
2479 ctx->current_scope = cbm_scope_push(ctx->arena, ctx->current_scope);
2480
2481 /* Determine func short name + QN. */
2482 const char *short_name = NULL;
2483 if (is_method) {
2484 TSNode nm = ts_node_child_by_field_name(node, "name", 4);
2485 if (!ts_node_is_null(nm))
2486 short_name = cs_node_text(ctx, nm);
2487 } else if (is_ctor) {
2488 short_name = ".ctor";
2489 } else if (is_dtor) {
2490 short_name = ".dtor";
2491 } else if (is_property) {
2492 TSNode nm = ts_node_child_by_field_name(node, "name", 4);
2493 if (!ts_node_is_null(nm))
2494 short_name = cs_node_text(ctx, nm);
2495 } else if (is_indexer) {
2496 short_name = "this[]";
2497 } else if (is_op) {
2498 TSNode op = ts_node_child_by_field_name(node, "operator", 8);
2499 if (!ts_node_is_null(op))
2500 short_name = cs_node_text(ctx, op);
2501 }
2502
2503 if (short_name) {
2504 if (ctx->enclosing_class_qn) {
2505 ctx->enclosing_func_qn =
2506 cbm_arena_sprintf(ctx->arena, "%s.%s", ctx->enclosing_class_qn, short_name);
2507 } else if (ctx->module_qn) {
2508 ctx->enclosing_func_qn =
2509 cbm_arena_sprintf(ctx->arena, "%s.%s", ctx->module_qn, short_name);
2510 } else {
2511 ctx->enclosing_func_qn = cbm_arena_strdup(ctx->arena, short_name);
2512 }
2513 }
2514
2515 /* Collect generic type parameters. */
2516 if (is_method) {
2517 const char **tp_names = NULL;
2518 int tp_count = 0;
2519 cs_collect_type_params(ctx, node, &tp_names, &tp_count);

Callers 1

cs_process_type_declFunction · 0.85

Calls 11

cbm_scope_pushFunction · 0.85
cs_node_textFunction · 0.85
cs_collect_type_paramsFunction · 0.85
cbm_type_type_paramFunction · 0.85
cs_child_named_kindFunction · 0.85
cs_bind_parametersFunction · 0.85
cs_first_named_childFunction · 0.85
cs_resolve_calls_in_nodeFunction · 0.85
cbm_arena_sprintfFunction · 0.50
cbm_arena_strdupFunction · 0.50
cbm_arena_allocFunction · 0.50

Tested by

no test coverage detected