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

Function doc_run_first

internal/cbm/extract_defs.c:2153–2170  ·  view source on GitHub ↗

First index of the run that ends at `near`: contiguous, one style (a Go * comment group mixes styles), not the previous code's trailing comment. */

Source from the content-addressed store, hash-verified

2151/* First index of the run that ends at `near`: contiguous, one style (a Go
2152 * comment group mixes styles), not the previous code's trailing comment. */
2153static int doc_run_first(CBMLanguage lang, const doc_trivia_t *t, int near) {
2154 int style = t->items[near].style;
2155 int first = near;
2156 for (int j = near - SKIP_ONE; j >= 0; j--) {
2157 const doc_span_t *sp = &t->items[j];
2158 if (sp->kind != DOC_SPAN_COMMENT || t->items[j + SKIP_ONE].srow > sp->erow + SKIP_ONE) {
2159 break; /* an attribute or a blank line ends the run */
2160 }
2161 if (lang != CBM_LANG_GO && sp->style != style) {
2162 break;
2163 }
2164 if (j == 0 && t->code_before && sp->srow == t->code_erow) {
2165 break;
2166 }
2167 first = j;
2168 }
2169 return first;
2170}
2171
2172/* The doc of an anchor from its leading trivia. */
2173static const char *doc_from_trivia(CBMExtractCtx *ctx, const doc_trivia_t *t,

Callers 1

doc_from_triviaFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected