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

Function cs_collect

internal/cbm/doclink_cs.c:2366–2380  ·  view source on GitHub ↗

Collect the declarations under `root` in document order. `owner` is the * item of the type whose members a node holds (CS_OWNER_NONE outside a type). * Preprocessor blocks and error nodes are looked into: a declaration that * parsed is a declaration wherever recovery left it, and its placement is * checked against the braces afterwards. What sits in an error node belongs * to whichever block'

Source from the content-addressed store, hash-verified

2364 * The walk keeps its own stack: how deep declarations nest is the file's
2365 * choice, and must not be this thread's stack depth. */
2366static void cs_collect(cs_scan_t *s, TSNode root, int owner) {
2367 cs_walk_stack_t w = {0};
2368 bool ok = !s->failed && cs_walk_push(s, &w, root, owner);
2369 while (w.count > 0) {
2370 /* a child may push a frame, which moves the array: no pointer into it
2371 * is kept across cs_collect_child */
2372 TSNode c;
2373 if (!ok || s->failed || !cs_kids_next_named(&w.frames[w.count - SKIP_ONE].kids, &c)) {
2374 cs_kids_end(&w.frames[w.count - SKIP_ONE].kids);
2375 w.count--;
2376 continue;
2377 }
2378 ok = cs_collect_child(s, &w, c, w.frames[w.count - SKIP_ONE].owner);
2379 }
2380}
2381
2382/* ── Declarations the tree has no node for ───────────────────────── */
2383

Callers 1

Calls 4

cs_walk_pushFunction · 0.85
cs_kids_next_namedFunction · 0.85
cs_kids_endFunction · 0.85
cs_collect_childFunction · 0.85

Tested by

no test coverage detected