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

Function process_local_var_decl

internal/cbm/lsp/java_lsp.c:1393–1422  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1391}
1392
1393static void process_local_var_decl(JavaLSPContext *ctx, TSNode node) {
1394 TSNode type_node = ts_node_child_by_field_name(node, "type", 4);
1395 const CBMType *static_type =
1396 ts_node_is_null(type_node) ? cbm_type_unknown() : java_parse_type_node(ctx, type_node);
1397 bool is_var =
1398 !ts_node_is_null(type_node) && strcmp(ts_node_type(type_node), "type_identifier") == 0 && ({
1399 char *txt = java_node_text(ctx, type_node);
1400 txt &&strcmp(txt, "var") == 0;
1401 });
1402
1403 /* Walk variable_declarator children. */
1404 uint32_t n = ts_node_named_child_count(node);
1405 for (uint32_t i = 0; i < n; i++) {
1406 TSNode c = ts_node_named_child(node, i);
1407 if (strcmp(ts_node_type(c), "variable_declarator") != 0)
1408 continue;
1409 TSNode name_node = ts_node_child_by_field_name(c, "name", 4);
1410 TSNode value_node = ts_node_child_by_field_name(c, "value", 5);
1411 if (ts_node_is_null(name_node))
1412 continue;
1413 char *vname = java_node_text(ctx, name_node);
1414 if (!vname)
1415 continue;
1416 const CBMType *bind_type = static_type;
1417 if ((is_var || cbm_type_is_unknown(bind_type)) && !ts_node_is_null(value_node)) {
1418 bind_type = java_eval_expr_type(ctx, value_node);
1419 }
1420 cbm_scope_bind(ctx->current_scope, vname, bind_type ? bind_type : cbm_type_unknown());
1421 }
1422}
1423
1424static void process_enhanced_for(JavaLSPContext *ctx, TSNode node) {
1425 TSNode type_node = ts_node_child_by_field_name(node, "type", 4);

Callers 1

java_process_statementFunction · 0.85

Calls 6

cbm_type_unknownFunction · 0.85
java_parse_type_nodeFunction · 0.85
java_node_textFunction · 0.85
cbm_type_is_unknownFunction · 0.85
java_eval_expr_typeFunction · 0.85
cbm_scope_bindFunction · 0.85

Tested by

no test coverage detected