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

Function nest_path_from_args

internal/cbm/extract_defs.c:3272–3298  ·  view source on GitHub ↗

The route path a Nest decorator's argument list carries. Accepted shapes: * () -> "/" * ('users') / (['a', 'b']) -> the (first) string literal * ({ path: 'users', ... }) -> the `path` property (Nest's options form) * Any other first argument (a constant, a template) has no statically known * path: NULL, so no Route is invented for it. */

Source from the content-addressed store, hash-verified

3270 * Any other first argument (a constant, a template) has no statically known
3271 * path: NULL, so no Route is invented for it. */
3272static const char *nest_path_from_args(CBMArena *a, TSNode args, const char *source) {
3273 if (ts_node_is_null(args) || ts_node_named_child_count(args) == 0) {
3274 return "/";
3275 }
3276 TSNode arg = ts_node_named_child(args, 0);
3277 const char *kind = ts_node_type(arg);
3278 if (strcmp(kind, "array") == 0 && ts_node_named_child_count(arg) > 0) {
3279 return nest_path_from_string(a, ts_node_named_child(arg, 0), source);
3280 }
3281 if (strcmp(kind, "object") != 0) {
3282 return nest_path_from_string(a, arg, source);
3283 }
3284 uint32_t nc = ts_node_named_child_count(arg);
3285 for (uint32_t i = 0; i < nc; i++) {
3286 TSNode pair = ts_node_named_child(arg, i);
3287 if (strcmp(ts_node_type(pair), "pair") != 0) {
3288 continue;
3289 }
3290 TSNode key = ts_node_child_by_field_name(pair, TS_FIELD("key"));
3291 char *key_text = ts_node_is_null(key) ? NULL : cbm_node_text(a, key, source);
3292 if (key_text && strcmp(key_text, "path") == 0) {
3293 return nest_path_from_string(a, ts_node_child_by_field_name(pair, TS_FIELD("value")),
3294 source);
3295 }
3296 }
3297 return "/"; /* options object without `path` (e.g. only `host`) */
3298}
3299
3300/* A TS decorator's call_expression as (bare name, argument list). Returns the
3301 * name, or NULL when the callee is not a plain identifier. */

Callers 2

Calls 2

nest_path_from_stringFunction · 0.85
cbm_node_textFunction · 0.85

Tested by

no test coverage detected