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

Function rs_use_leaf

internal/cbm/doclink_rs.c:2946–2965  ·  view source on GitHub ↗

A leaf of a use tree: `full` is the whole path, `alias` the name after * `as` (NULL when there is none). `a::b::self` imports `b` itself, in the type * namespace only. */

Source from the content-addressed store, hash-verified

2944 * `as` (NULL when there is none). `a::b::self` imports `b` itself, in the type
2945 * namespace only. */
2946static void rs_use_leaf(rs_scan_t *s, int mod, TSNode decl, const char *full, const char *alias) {
2947 static const char self_seg[] = "::self";
2948 const size_t sl = sizeof(self_seg) - SKIP_ONE;
2949 char path[RS_SCAN_PATH_CAP];
2950 snprintf(path, sizeof(path), "%s", full);
2951 size_t n = strlen(path);
2952 char kind = 'b';
2953 if (n > sl && strcmp(path + n - sl, self_seg) == 0) {
2954 path[n - sl] = '\0';
2955 kind = 's';
2956 }
2957 const char *last = strrchr(path, ':');
2958 const char *local = alias ? alias : (last ? last + SKIP_ONE : path);
2959 bool keyword =
2960 strcmp(local, "crate") == 0 || strcmp(local, "super") == 0 || strcmp(local, "self") == 0;
2961 if (!local[0] || (keyword && !alias)) {
2962 return; /* `use crate;` binds nothing */
2963 }
2964 rs_rec_use(s, mod, decl, kind, local, path);
2965}
2966
2967/* The bindings of one `use` declaration: its tree is walked with a stack. */
2968static void rs_item_use(rs_scan_t *s, TSNode decl, int mod) {

Callers 1

rs_item_useFunction · 0.85

Calls 1

rs_rec_useFunction · 0.85

Tested by

no test coverage detected