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

Function gb_collect_spans

src/graph_buffer/graph_buffer.c:996–1020  ·  view source on GitHub ↗

Append a side's spans: its `variants` list, else its own span when it is a * definition. File paths are interned, so the spans outlive the props. */

Source from the content-addressed store, hash-verified

994/* Append a side's spans: its `variants` list, else its own span when it is a
995 * definition. File paths are interned, so the spans outlive the props. */
996static void gb_collect_spans(cbm_gbuf_t *gb, gb_span_vec_t *vec, const gb_def_t *d) {
997 if (gb_props_have_variants(d->props)) {
998 yyjson_doc *doc = yyjson_read_opts((char *)d->props, strlen(d->props), 0, &gb_yy_alc, NULL);
999 yyjson_val *list = gb_variants_list(doc);
1000 if (list) {
1001 size_t i;
1002 size_t max;
1003 yyjson_val *v;
1004 yyjson_arr_foreach(list, i, max, v) {
1005 const char *f = yyjson_get_str(yyjson_obj_get(v, "file_path"));
1006 int st = (int)yyjson_get_int(yyjson_obj_get(v, "start_line"));
1007 int en = (int)yyjson_get_int(yyjson_obj_get(v, "end_line"));
1008 if (f && st > 0) {
1009 gb_span_push(vec, (gb_span_t){gb_intern(gb, f), st, en});
1010 }
1011 }
1012 yyjson_doc_free(doc);
1013 return;
1014 }
1015 yyjson_doc_free(doc);
1016 }
1017 if (gb_variant_label(d->label) && d->start > 0) {
1018 gb_span_push(vec, (gb_span_t){gb_intern(gb, d->file ? d->file : ""), d->start, d->end});
1019 }
1020}
1021
1022/* Append spans gathered in another buffer (a worker's), re-interned here. */
1023static void gb_append_spans(cbm_gbuf_t *gb, gb_span_vec_t *vec, const gb_span_vec_t *from) {

Callers 1

gb_note_collisionFunction · 0.85

Calls 5

gb_props_have_variantsFunction · 0.85
gb_variants_listFunction · 0.85
gb_span_pushFunction · 0.85
gb_internFunction · 0.85
gb_variant_labelFunction · 0.85

Tested by

no test coverage detected