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 origin/main into fix/issue-1548-python-nested-defs-v2

Martin Vogelf6b505914a43
diff --cc src/pipeline/pass_definitions.c
index 80bf0a8a9,0f95c7989..7a6b5b271
--- a/src/pipeline/pass_definitions.c
+++ b/src/pipeline/pass_definitions.c
@@@ -412,11 -412,27 +412,28 @@@ static void pd_add_file_doc(const cbm_g
cbm_free(CBM_MEM_CLASS_GBUF_STRING, neu);
}
- /* Process one definition: create node, register, DEFINES + DEFINES_METHOD edges.
- * `file_doc`, the file's own doc (passed with its first def only), goes on the
- * File node. */
+ /* DEFINES_METHOD from a method's type, and the parent edge of a diagram
+ * element. Both look the parent up by QN, so the parent's node must exist. */
+ static void link_def_parents(cbm_pipeline_ctx_t *ctx, const CBMDefinition *def, int64_t node_id) {
+ if (node_id <= 0) {
+ return;
+ }
+ if (def->parent_class && def->label && strcmp(def->label, "Method") == 0) {
+ const cbm_gbuf_node_t *parent = cbm_gbuf_find_by_qn(ctx->gbuf, def->parent_class);
+ if (parent) {
+ cbm_gbuf_insert_edge(ctx->gbuf, parent->id, node_id, "DEFINES_METHOD", "{}");
+ }
+ }
+ cbm_pipeline_diagram_parent_edge(ctx, def, node_id);
+ }
+
+ /* Process one definition: create node, register, DEFINES edge. `file_doc`,
+ * the file's own doc (passed with its first def only), goes on the File node.
+ * `link_parents` links its DEFINES_METHOD / diagram parent right away; with
+ * the result cache the pass links them once every file is registered. */
static void process_def(cbm_pipeline_ctx_t *ctx, const CBMDefinition *def, const char *rel,
- const char *file_doc, CBMLanguage lang, size_t module_prefix_len) {
- const char *file_doc, CBMLanguage lang, bool link_parents) {
++ const char *file_doc, CBMLanguage lang, size_t module_prefix_len,
++ bool link_parents) {
if (!def->qualified_name || !def->name) {
return;
}
@@@ -1020,14 -1061,10 +1063,15 @@@ int cbm_pipeline_pass_definitions(cbm_p
"test_declarations");
}
- /* Create nodes for each definition */
+ /* Create nodes for each definition. A Python file's module QN bounds
+ * the registry's function-local detection to this file. */
const char *file_doc = result->module_doc; /* goes with the first def */
+ size_t py_prefix_len = lang == CBM_LANG_PYTHON
+ ? cbm_pipeline_fqn_symbol_prefix_len(ctx->project_name, rel)
+ : 0;
for (int d = 0; d < result->defs.count; d++) {
- process_def(ctx, &result->defs.items[d], rel, file_doc, lang, py_prefix_len);
- process_def(ctx, &result->defs.items[d], rel, file_doc, lang, !local_cache);
++ process_def(ctx, &result->defs.items[d], rel, file_doc, lang, py_prefix_len,
++ !local_cache);
file_doc = NULL;
total_defs++;
}