rows -> an array of shown candidates; the other end of each row is its * target (by_section) or its section. Returns how many resolved. */
| 13238 | /* rows -> an array of shown candidates; the other end of each row is its |
| 13239 | * target (by_section) or its section. Returns how many resolved. */ |
| 13240 | static int doc_candidates_array(yyjson_mut_doc *doc, yyjson_mut_val *arr, cbm_store_t *store, |
| 13241 | const char *project, const cbm_doc_candidate_t *rows, int n, |
| 13242 | bool by_section) { |
| 13243 | int added = 0; |
| 13244 | for (int i = 0; i < n; i++) { |
| 13245 | cbm_node_t other = {0}; |
| 13246 | if (cbm_store_find_node_by_qn(store, project, |
| 13247 | by_section ? rows[i].target_qn : rows[i].section_qn, |
| 13248 | &other) != CBM_STORE_OK) { |
| 13249 | continue; |
| 13250 | } |
| 13251 | yyjson_mut_val *o = yyjson_mut_obj(doc); |
| 13252 | yyjson_mut_obj_add_strcpy(doc, o, by_section ? "qualified_name" : "section", |
| 13253 | other.qualified_name ? other.qualified_name : ""); |
| 13254 | if (by_section) { |
| 13255 | yyjson_mut_obj_add_strcpy(doc, o, "label", other.label ? other.label : ""); |
| 13256 | } |
| 13257 | yyjson_mut_obj_add_strcpy(doc, o, "file_path", other.file_path ? other.file_path : ""); |
| 13258 | yyjson_mut_obj_add_int(doc, o, "start_line", other.start_line); |
| 13259 | if (by_section) { |
| 13260 | yyjson_mut_obj_add_int(doc, o, "end_line", other.end_line); |
| 13261 | } |
| 13262 | yyjson_mut_obj_add_real(doc, o, "p", (double)(int)(rows[i].p * 1000.0 + 0.5) / 1000.0); |
| 13263 | doc_candidate_evidence(doc, o, rows[i].evidence, by_section); |
| 13264 | yyjson_mut_arr_append(arr, o); |
| 13265 | added++; |
| 13266 | free_node_contents(&other); |
| 13267 | } |
| 13268 | return added; |
| 13269 | } |
| 13270 | |
| 13271 | static void add_doc_candidates(yyjson_mut_doc *doc, yyjson_mut_val *root, cbm_store_t *store, |
| 13272 | const cbm_node_t *node) { |
no test coverage detected