True iff a CALLS edge exists from a node named src_name to a node named * tgt_name. Used to assert cross-file call resolution survives a reindex. */
| 818 | /* True iff a CALLS edge exists from a node named src_name to a node named |
| 819 | * tgt_name. Used to assert cross-file call resolution survives a reindex. */ |
| 820 | static bool cross_file_call_exists(cbm_store_t *s, const char *project, const char *src_name, |
| 821 | const char *tgt_name) { |
| 822 | cbm_node_t *srcs = NULL; |
| 823 | cbm_node_t *tgts = NULL; |
| 824 | int sc = 0; |
| 825 | int tc = 0; |
| 826 | cbm_store_find_nodes_by_name(s, project, src_name, &srcs, &sc); |
| 827 | cbm_store_find_nodes_by_name(s, project, tgt_name, &tgts, &tc); |
| 828 | bool found = false; |
| 829 | for (int i = 0; i < sc && !found; i++) { |
| 830 | cbm_edge_t *edges = NULL; |
| 831 | int ec = 0; |
| 832 | cbm_store_find_edges_by_source_type(s, srcs[i].id, "CALLS", &edges, &ec); |
| 833 | for (int j = 0; j < ec && !found; j++) { |
| 834 | for (int k = 0; k < tc; k++) { |
| 835 | if (edges[j].target_id == tgts[k].id) { |
| 836 | found = true; |
| 837 | break; |
| 838 | } |
| 839 | } |
| 840 | } |
| 841 | if (edges) { |
| 842 | cbm_store_free_edges(edges, ec); |
| 843 | } |
| 844 | } |
| 845 | if (srcs) { |
| 846 | cbm_store_free_nodes(srcs, sc); |
| 847 | } |
| 848 | if (tgts) { |
| 849 | cbm_store_free_nodes(tgts, tc); |
| 850 | } |
| 851 | return found; |
| 852 | } |
| 853 | |
| 854 | /* Regression: incremental re-index of an edited file must NOT drop inbound |
| 855 | * cross-file CALLS edges whose source lives in an UNCHANGED file. |
no test coverage detected