Skip to content

Local code intelligence for developers and AI agents. Connect code, docs and infrastructure in a persistent graph, with CBM Lens, MCP tools, agent integrations and change-aware test selection.

Merge branch 'main' into fix/py-definitions-oom

Martin Vogel64349dedab73
diff --cc internal/cbm/lsp/py_lsp.c
index a4c39e214,9d3cf486e..f71529a9d
--- a/internal/cbm/lsp/py_lsp.c
+++ b/internal/cbm/lsp/py_lsp.c
@@@ -165,8 -245,22 +245,22 @@@ static void py_register_instance_field(
static void py_bind_for_target(PyLSPContext *ctx, TSNode left, const CBMType *elem_type);
static void py_register_lambda(PyLSPContext *ctx, const char *name, TSNode lambda_node);
static void py_register_dict_literal(PyLSPContext *ctx, const char *name, TSNode dict_node);
-static TSNode py_lookup_lambda(PyLSPContext *ctx, const char *name);
+static int py_lookup_lambda(PyLSPContext *ctx, const char *name);
static const char *py_lookup_dict_dispatch(PyLSPContext *ctx, const char *var, const char *key);
+ static void py_process_function(PyLSPContext *ctx, TSNode func_node, const char *container_qn);
+ static void py_process_class(PyLSPContext *ctx, TSNode class_node);
+ static void py_process_class_in(PyLSPContext *ctx, TSNode class_node, const char *container_qn);
+ typedef enum { PY_LOCAL_DEFS_BIND, PY_LOCAL_DEFS_PROCESS } PyLocalDefsMode;
+ static void py_visit_local_defs(PyLSPContext *ctx, TSNode block, PyLocalDefsMode mode, int depth);
+
+ /* A name looked up in a module namespace: the module's own function or
+ * class, or the definition the module re-exports under that name. At most
+ * one of func/type is set. */
+ typedef struct {
+ const CBMRegisteredFunc *func;
+ const CBMRegisteredType *type;
+ } PyModuleMember;
+ static PyModuleMember py_module_member(PyLSPContext *ctx, const char *module_qn, const char *name);
/* ── Scope mutation wrappers ─────────────────────────────────────────────
*
@@@ -2519,9 -3154,12 +3156,12 @@@ static void py_emit_call_for(PyLSPConte
// Walk the lambda body for any nested call sites with the params
// bound to the call's arg types. Resolved calls get caller_qn
// set to a synthetic <lambda> child of the enclosing function.
- int lambda_idx = py_lookup_lambda(ctx, fname);
+ /* These legacy entries have no lexical frame identity. During class
+ * execution, leave lambda replay unresolved instead of bypassing a
+ * local shadow or running the lambda against class locals. */
- TSNode lambda_node =
- ctx->class_body_outer_scope ? (TSNode){0} : py_lookup_lambda(ctx, fname);
- if (!ts_node_is_null(lambda_node)) {
++ int lambda_idx = ctx->class_body_outer_scope ? -1 : py_lookup_lambda(ctx, fname);
+ if (lambda_idx >= 0) {
+ TSNode lambda_node = ctx->lambdas[lambda_idx].lambda_node;
TSNode params = ts_node_child_by_field_name(lambda_node, "parameters", 10);
TSNode body = ts_node_child_by_field_name(lambda_node, "body", 4);
TSNode args = ts_node_child_by_field_name(call_node, "arguments", 9);