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

Function cs_emit_using

internal/cbm/doclink_cs.c:2576–2631  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2574}
2575
2576static void cs_emit_using(cs_scan_t *s, TSNode u, int region) {
2577 bool is_global = false;
2578 bool is_static = false;
2579 bool is_alias = false;
2580 cs_kids_t k = cs_kids(u);
2581 TSNode ch;
2582 while (cs_kids_next(&k, &ch)) {
2583 if (ts_node_is_named(ch)) {
2584 continue;
2585 }
2586 const char *t = ts_node_type(ch);
2587 if (strcmp(t, "global") == 0) {
2588 is_global = true;
2589 } else if (strcmp(t, "static") == 0) {
2590 is_static = true;
2591 } else if (strcmp(t, "=") == 0) {
2592 is_alias = true;
2593 }
2594 }
2595 cs_kids_end(&k);
2596 TSNode alias = is_alias ? cs_field(u, "name") : (TSNode){0};
2597 TSNode target = {0};
2598 k = cs_kids(u);
2599 while (cs_kids_next_named(&k, &ch)) {
2600 if (is_alias && ts_node_eq(ch, alias)) {
2601 continue;
2602 }
2603 if (cs_kind_is(ch, "comment")) {
2604 continue;
2605 }
2606 target = ch;
2607 }
2608 cs_kids_end(&k);
2609 if (ts_node_is_null(target)) {
2610 return;
2611 }
2612 /* what the directive brings in, and whom it serves: `global using` (of a
2613 * namespace, of a type's static members, of an alias alike) is in scope in
2614 * every file of the project */
2615 sb_puts(&s->sb, "U\t");
2616 sb_putu(&s->sb, (uint32_t)region);
2617 sb_putc(&s->sb, '\t');
2618 sb_putc(&s->sb, is_alias ? 'a' : (is_static ? 's' : 'n'));
2619 if (is_global) {
2620 sb_putc(&s->sb, 'g');
2621 }
2622 sb_putc(&s->sb, '\t');
2623 if (is_alias && !ts_node_is_null(alias)) {
2624 cs_put_text_nows(s, alias);
2625 } else {
2626 sb_putc(&s->sb, '-');
2627 }
2628 sb_putc(&s->sb, '\t');
2629 cs_put_text_nows(s, target);
2630 sb_putc(&s->sb, '\n');
2631}
2632
2633/* Lines [from, to] hold declarations that could not be placed. */

Callers 1

cs_emit_itemsFunction · 0.85

Calls 10

cs_kidsFunction · 0.85
cs_kids_nextFunction · 0.85
cs_kids_endFunction · 0.85
cs_fieldFunction · 0.85
cs_kids_next_namedFunction · 0.85
cs_kind_isFunction · 0.85
sb_putsFunction · 0.85
sb_putuFunction · 0.85
sb_putcFunction · 0.85
cs_put_text_nowsFunction · 0.85

Tested by

no test coverage detected