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. */
| 416 | * `file_doc`, the file's own doc (passed with its first def only), goes on the |
| 417 | * File node. */ |
| 418 | static void process_def(cbm_pipeline_ctx_t *ctx, const CBMDefinition *def, const char *rel, |
| 419 | const char *file_doc, CBMLanguage lang) { |
| 420 | if (!def->qualified_name || !def->name) { |
| 421 | return; |
| 422 | } |
| 423 | char stack[CBM_SZ_2K]; |
| 424 | size_t props_size = sizeof(stack); |
| 425 | char *props = pd_props_buf(def, stack, &props_size); |
| 426 | build_def_props(props, props_size, def); |
| 427 | const char *def_rel = def->file_path ? def->file_path : rel; |
| 428 | char marked[CBM_SZ_4K]; |
| 429 | const char *qn = def->label && strcmp(def->label, "Module") == 0 |
| 430 | ? cbm_stem_marks_module_qn(ctx->stem_marks, def->qualified_name, def_rel, |
| 431 | lang, marked, sizeof(marked)) |
| 432 | : def->qualified_name; |
| 433 | int64_t node_id = |
| 434 | cbm_gbuf_upsert_node(ctx->gbuf, def->label ? def->label : "Function", def->name, qn, |
| 435 | def_rel, (int)def->start_line, (int)def->end_line, props); |
| 436 | if (props != stack) { |
| 437 | cbm_free(CBM_MEM_CLASS_GBUF_STRING, props); |
| 438 | } |
| 439 | /* Registry membership is defined ONCE by cbm_label_is_registry_symbol |
| 440 | * (helpers.c): callables + type-like containers (INHERITS/IMPLEMENTS/method/ |
| 441 | * field resolution), Variable/Field (READS/WRITES resolution), and Table/View |
| 442 | * (SQL FROM/JOIN lineage). pass_parallel.c and pipeline_incremental.c seed |
| 443 | * through the same predicate, so the three registries cannot diverge. */ |
| 444 | if (node_id > 0 && cbm_label_is_registry_symbol(def->label)) { |
| 445 | cbm_registry_add_lang(ctx->registry, def->name, def->qualified_name, def->label, lang); |
| 446 | } |
| 447 | char *file_qn = cbm_pipeline_fqn_compute(ctx->project_name, rel, "__file__"); |
| 448 | const cbm_gbuf_node_t *file_node = cbm_gbuf_find_by_qn(ctx->gbuf, file_qn); |
| 449 | pd_add_file_doc(file_node, file_doc); |
| 450 | if (file_node && node_id > 0) { |
| 451 | cbm_gbuf_insert_edge(ctx->gbuf, file_node->id, node_id, "DEFINES", "{}"); |
| 452 | } |
| 453 | free(file_qn); |
| 454 | if (def->parent_class && def->label && strcmp(def->label, "Method") == 0) { |
| 455 | const cbm_gbuf_node_t *parent = cbm_gbuf_find_by_qn(ctx->gbuf, def->parent_class); |
| 456 | if (parent && node_id > 0) { |
| 457 | cbm_gbuf_insert_edge(ctx->gbuf, parent->id, node_id, "DEFINES_METHOD", "{}"); |
| 458 | } |
| 459 | } |
| 460 | cbm_pipeline_diagram_parent_edge(ctx, def, node_id); |
| 461 | } |
| 462 | |
| 463 | /* Create Channel nodes + EMITS / LISTENS_ON edges for one file's channels. |
| 464 | * Mirrors the parallel path in cbm_build_registry_from_cache — keep in sync. */ |
no test coverage detected