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

Function dotted_name

internal/cbm/extract_url_fold.c:240–259  ·  view source on GitHub ↗

"A.B.C" for a JS member chain over identifiers, or false. */

Source from the content-addressed store, hash-verified

238
239/* "A.B.C" for a JS member chain over identifiers, or false. */
240static bool dotted_name(CBMExtractCtx *ctx, TSNode node, char *out, size_t cap, int depth) {
241 const char *k = ts_node_type(node);
242 if (strcmp(k, "identifier") == 0) {
243 const char *t = cbm_node_text(ctx->arena, node, ctx->source);
244 return t && snprintf(out, cap, "%s", t) < (int)cap;
245 }
246 if (strcmp(k, "member_expression") != 0 || depth >= FOLD_MAX_OBJ_DEPTH) {
247 return false;
248 }
249 TSNode obj = ts_node_child_by_field_name(node, TS_FIELD("object"));
250 TSNode prop = ts_node_child_by_field_name(node, TS_FIELD("property"));
251 if (ts_node_is_null(obj) || ts_node_is_null(prop) ||
252 strcmp(ts_node_type(prop), "property_identifier") != 0 ||
253 !dotted_name(ctx, obj, out, cap, depth + SKIP_ONE)) {
254 return false;
255 }
256 const char *p = cbm_node_text(ctx->arena, prop, ctx->source);
257 size_t used = strlen(out);
258 return p && snprintf(out + used, cap - used, ".%s", p) < (int)(cap - used);
259}
260
261static const char *fold_reference(CBMExtractCtx *ctx, TSNode node, bool url) {
262 char name[FOLD_NAME_BUF];

Callers 1

fold_referenceFunction · 0.85

Calls 1

cbm_node_textFunction · 0.85

Tested by

no test coverage detected