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. */
| 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. */ |
| 996 | static 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. */ |
| 1023 | static void gb_append_spans(cbm_gbuf_t *gb, gb_span_vec_t *vec, const gb_span_vec_t *from) { |
no test coverage detected