| 136 | } |
| 137 | |
| 138 | static void ts_push(const ts_emit_t *em, const char *ref, size_t n, int syntax, uint32_t line) { |
| 139 | if (n == 0) { |
| 140 | return; |
| 141 | } |
| 142 | if (n > CBM_DOCLINK_TS_REF_MAX) { |
| 143 | n = CBM_DOCLINK_TS_REF_MAX + SKIP_ONE; /* clipped: the resolver calls it unparseable */ |
| 144 | } |
| 145 | if (ts_is_url(ref, n)) { |
| 146 | syntax = CBM_DOCLINK_HREF; |
| 147 | } else { |
| 148 | size_t k = 0; |
| 149 | while (k < n && ts_ident_char(ref[k])) { |
| 150 | k++; |
| 151 | } |
| 152 | if (k == n && ts_is_param(em->def, ref, n)) { |
| 153 | return; /* the declaration's own parameter */ |
| 154 | } |
| 155 | } |
| 156 | char *copy = cbm_arena_strndup(em->ctx->arena, ref, n); |
| 157 | if (!copy) { |
| 158 | return; |
| 159 | } |
| 160 | CBMDocLink link = { |
| 161 | .source_qn = em->def->qualified_name, |
| 162 | .raw = copy, |
| 163 | .line = line, |
| 164 | .def_line = em->def->start_line, |
| 165 | .syntax = (uint16_t)syntax, |
| 166 | }; |
| 167 | cbm_doclinks_push(&em->ctx->result->doc_links, em->ctx->arena, link); |
| 168 | } |
| 169 | |
| 170 | /* One doc line: its text after the leading `*`, and its source line. */ |
| 171 | typedef struct { |
no test coverage detected