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

Function try_generic_path_fields

internal/cbm/extract_imports.c:1441–1456  ·  view source on GitHub ↗

Try known field names (path/source/module/name) to extract import path.

Source from the content-addressed store, hash-verified

1439
1440// Try known field names (path/source/module/name) to extract import path.
1441static bool try_generic_path_fields(CBMExtractCtx *ctx, TSNode node) {
1442 CBMArena *a = ctx->arena;
1443 static const char *path_fields[] = {"path", "source", "module", "name", NULL};
1444 for (const char **f = path_fields; *f; f++) {
1445 TSNode path_node = ts_node_child_by_field_name(node, *f, (uint32_t)strlen(*f));
1446 if (!ts_node_is_null(path_node)) {
1447 char *path = strip_quotes(a, cbm_node_text(a, path_node, ctx->source));
1448 if (path && path[0]) {
1449 CBMImport imp = {.local_name = path_last(a, path), .module_path = path};
1450 cbm_imports_push(&ctx->result->imports, a, imp);
1451 }
1452 return true;
1453 }
1454 }
1455 return false;
1456}
1457
1458// Fallback: extract import path from full node text, stripping keyword and semicolon.
1459static void generic_import_from_text(CBMExtractCtx *ctx, TSNode node) {

Callers 5

parse_generic_importsFunction · 0.85
parse_php_importsFunction · 0.85
parse_csharp_importsFunction · 0.85
parse_spec_importsFunction · 0.85

Calls 4

cbm_node_textFunction · 0.85
path_lastFunction · 0.85
cbm_imports_pushFunction · 0.85
strip_quotesFunction · 0.70

Tested by

no test coverage detected