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

Function ts_process_statement

internal/cbm/lsp/ts_lsp.c:2221–2262  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2219}
2220
2221void ts_process_statement(TSLSPContext *ctx, TSNode node) {
2222 if (!ctx || ts_node_is_null(node))
2223 return;
2224 const char *kind = ts_node_type(node);
2225
2226 if (strcmp(kind, "lexical_declaration") == 0 || strcmp(kind, "variable_declaration") == 0) {
2227 uint32_t nc = ts_node_named_child_count(node);
2228 for (uint32_t i = 0; i < nc; i++) {
2229 TSNode c = ts_node_named_child(node, i);
2230 if (node_kind_is(c, "variable_declarator"))
2231 bind_variable_declarator(ctx, c);
2232 }
2233 } else if (strcmp(kind, "for_in_statement") == 0 || strcmp(kind, "for_of_statement") == 0) {
2234 TSNode left = ts_node_child_by_field_name(node, "left", TS_LSP_FIELD_LEN("left"));
2235 TSNode right = ts_node_child_by_field_name(node, "right", TS_LSP_FIELD_LEN("right"));
2236 if (!ts_node_is_null(left) && !ts_node_is_null(right)) {
2237 const CBMType *iter = ts_eval_expr_type(ctx, right);
2238 const CBMType *elem = cbm_type_unknown();
2239 if (iter && iter->kind == CBM_TYPE_TEMPLATE && iter->data.template_type.template_args &&
2240 iter->data.template_type.arg_count >= 1) {
2241 elem = iter->data.template_type.template_args[0];
2242 }
2243 // left is typically `lexical_declaration` of `(let x of arr)` or bare identifier.
2244 if (node_kind_is(left, "lexical_declaration") ||
2245 node_kind_is(left, "variable_declaration")) {
2246 TSNode v = ts_node_named_child(left, 0);
2247 if (node_kind_is(v, "variable_declarator")) {
2248 TSNode nm = ts_node_child_by_field_name(v, "name", TS_LSP_FIELD_LEN("name"));
2249 if (node_kind_is(nm, "identifier")) {
2250 char *s = node_text(ctx, nm);
2251 if (s)
2252 cbm_scope_bind(ctx->current_scope, s, elem);
2253 }
2254 }
2255 } else if (node_kind_is(left, "identifier")) {
2256 char *s = node_text(ctx, left);
2257 if (s)
2258 cbm_scope_bind(ctx->current_scope, s, elem);
2259 }
2260 }
2261 }
2262}
2263
2264// ── Call resolution + tree walk ───────────────────────────────────────────────
2265

Callers 2

process_nodeFunction · 0.85
ts_lsp_process_fileFunction · 0.85

Calls 6

node_kind_isFunction · 0.85
bind_variable_declaratorFunction · 0.85
ts_eval_expr_typeFunction · 0.85
cbm_type_unknownFunction · 0.85
node_textFunction · 0.85
cbm_scope_bindFunction · 0.85

Tested by

no test coverage detected