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

Function process_es_import_statement

internal/cbm/extract_imports.c:397–428  ·  view source on GitHub ↗

Process a single ES import_statement node. Returns true if fully handled. */

Source from the content-addressed store, hash-verified

395
396/* Process a single ES import_statement node. Returns true if fully handled. */
397static bool process_es_import_statement(CBMExtractCtx *ctx, TSNode node) {
398 CBMArena *a = ctx->arena;
399 TSNode source_node = find_es_source_node(node);
400 if (ts_node_is_null(source_node)) {
401 return false;
402 }
403 char *path = strip_quotes(a, cbm_node_text(a, source_node, ctx->source));
404 if (!path || !path[0]) {
405 return false;
406 }
407 uint32_t nc = ts_node_child_count(node);
408 bool found = false;
409 for (uint32_t j = 0; j < nc; j++) {
410 TSNode child = ts_node_child(node, j);
411 const char *ck = ts_node_type(child);
412 if (strcmp(ck, "identifier") == 0) {
413 char *name = cbm_node_text(a, child, ctx->source);
414 CBMImport imp = {.local_name = name, .module_path = path};
415 cbm_imports_push(&ctx->result->imports, a, imp);
416 found = true;
417 } else if (strcmp(ck, "import_clause") == 0) {
418 if (process_import_clause(ctx, child, path)) {
419 found = true;
420 }
421 }
422 }
423 if (!found) {
424 CBMImport imp = {.local_name = path_last(a, path), .module_path = path};
425 cbm_imports_push(&ctx->result->imports, a, imp);
426 }
427 return true;
428}
429
430/* Handle CommonJS `require("path")` call_expression nodes. The local name
431 * is derived from the enclosing variable_declarator / assignment when

Callers 1

walk_es_importsFunction · 0.85

Calls 6

find_es_source_nodeFunction · 0.85
cbm_node_textFunction · 0.85
cbm_imports_pushFunction · 0.85
process_import_clauseFunction · 0.85
path_lastFunction · 0.85
strip_quotesFunction · 0.70

Tested by

no test coverage detected