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

Function py_bind_module_function

internal/cbm/lsp/py_lsp.c:4782–4806  ·  view source on GitHub ↗

Preserve the historical registry fallback for an unshadowed function: it * keeps ordinary direct-call resolution stable. When a definition actually * replaces a prior binding (import, wildcard uncertainty, class, assignment), * record the new exact callable value or clear the stale identity. */

Source from the content-addressed store, hash-verified

4780 * replaces a prior binding (import, wildcard uncertainty, class, assignment),
4781 * record the new exact callable value or clear the stale identity. */
4782static void py_bind_module_function(PyLSPContext *ctx, TSNode func_node) {
4783 if (!ctx || ts_node_is_null(func_node) || !ctx->module_qn)
4784 return;
4785 TSNode name_node = ts_node_child_by_field_name(func_node, "name", 4);
4786 char *name = py_node_text(ctx, name_node);
4787 if (!name || !name[0]) {
4788 py_disable_callable_value_proof(ctx);
4789 return;
4790 }
4791 if (!cbm_scope_contains(ctx->current_scope, name))
4792 return;
4793
4794 const char *qn = cbm_arena_sprintf(ctx->arena, "%s.%s", ctx->module_qn, name);
4795 if (!qn) {
4796 py_disable_callable_value_proof(ctx);
4797 py_scope_bind(ctx, name, cbm_type_unknown());
4798 return;
4799 }
4800 const CBMRegisteredFunc *func = cbm_registry_lookup_func(ctx->registry, qn);
4801 if (py_func_is_exact_callable_value(func)) {
4802 py_scope_bind_callable(ctx, name, cbm_type_unknown(), func->qualified_name);
4803 } else {
4804 py_scope_bind(ctx, name, cbm_type_unknown());
4805 }
4806}
4807
4808static bool py_import_statement_is_wildcard(TSNode stmt) {
4809 uint32_t count = ts_node_named_child_count(stmt);

Callers 1

py_lsp_process_fileFunction · 0.85

Calls 9

py_node_textFunction · 0.85
cbm_scope_containsFunction · 0.85
py_scope_bindFunction · 0.85
cbm_type_unknownFunction · 0.85
cbm_registry_lookup_funcFunction · 0.85
py_scope_bind_callableFunction · 0.85
cbm_arena_sprintfFunction · 0.50

Tested by

no test coverage detected