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

Function parse_ruby_imports

internal/cbm/extract_imports.c:1255–1283  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1253}
1254
1255static void parse_ruby_imports(CBMExtractCtx *ctx) {
1256 CBMArena *a = ctx->arena;
1257
1258 TSTreeCursor cursor = ts_tree_cursor_new(ctx->root);
1259 if (!ts_tree_cursor_goto_first_child(&cursor)) {
1260 ts_tree_cursor_delete(&cursor);
1261 return;
1262 }
1263 do {
1264 TSNode node = ts_tree_cursor_current_node(&cursor);
1265 const char *kind = ts_node_type(node);
1266 if (strcmp(kind, "call") != 0 && strcmp(kind, "command_call") != 0) {
1267 continue;
1268 }
1269
1270 if (!ruby_require_method(a, node, ctx->source)) {
1271 continue;
1272 }
1273
1274 char *arg_text = extract_ruby_require_arg(a, node, ctx->source);
1275 if (!arg_text || !arg_text[0]) {
1276 continue;
1277 }
1278
1279 CBMImport imp = {.local_name = path_last(a, arg_text), .module_path = arg_text};
1280 cbm_imports_push(&ctx->result->imports, a, imp);
1281 } while (ts_tree_cursor_goto_next_sibling(&cursor));
1282 ts_tree_cursor_delete(&cursor);
1283}
1284
1285// --- Lua imports ---
1286// function_call: require("X")

Callers 1

cbm_extract_importsFunction · 0.85

Calls 4

ruby_require_methodFunction · 0.85
extract_ruby_require_argFunction · 0.85
path_lastFunction · 0.85
cbm_imports_pushFunction · 0.85

Tested by

no test coverage detected