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

Function c_static_names

internal/cbm/doclink_c.c:594–616  ·  view source on GitHub ↗

The names a static declaration or definition declares. */

Source from the content-addressed store, hash-verified

592
593/* The names a static declaration or definition declares. */
594static void c_static_names(CBMExtractCtx *ctx, CBMHashTable *names, TSNode decl) {
595 if (!c_is_static(ctx->source, decl)) {
596 return;
597 }
598 TSTreeCursor cur = ts_tree_cursor_new(decl);
599 for (bool more = ts_tree_cursor_goto_first_child(&cur); more;
600 more = ts_tree_cursor_goto_next_sibling(&cur)) {
601 const char *field = ts_tree_cursor_current_field_name(&cur);
602 if (!field || strcmp(field, "declarator") != 0) {
603 continue;
604 }
605 TSNode name = c_declarator_name(ts_tree_cursor_current_node(&cur));
606 if (ts_node_is_null(name)) {
607 continue;
608 }
609 uint32_t b = ts_node_start_byte(name);
610 char *key = cbm_arena_strndup(ctx->arena, ctx->source + b, ts_node_end_byte(name) - b);
611 if (key) {
612 cbm_ht_set(names, key, (void *)(uintptr_t)SKIP_ONE);
613 }
614 }
615 ts_tree_cursor_delete(&cur);
616}
617
618/* The static names of the file: top-level declarations, also inside
619 * preprocessor conditionals and extern "C" blocks. */

Callers 1

c_collect_staticFunction · 0.85

Calls 4

c_is_staticFunction · 0.85
c_declarator_nameFunction · 0.85
cbm_ht_setFunction · 0.85
cbm_arena_strndupFunction · 0.70

Tested by

no test coverage detected