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:408–439  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

406
407/* Process a single ES import_statement node. Returns true if fully handled. */
408static bool process_es_import_statement(CBMExtractCtx *ctx, TSNode node) {
409 CBMArena *a = ctx->arena;
410 TSNode source_node = find_es_source_node(node);
411 if (ts_node_is_null(source_node)) {
412 return false;
413 }
414 char *path = strip_quotes(a, cbm_node_text(a, source_node, ctx->source));
415 if (!path || !path[0]) {
416 return false;
417 }
418 uint32_t nc = ts_node_child_count(node);
419 bool found = false;
420 for (uint32_t j = 0; j < nc; j++) {
421 TSNode child = ts_node_child(node, j);
422 const char *ck = ts_node_type(child);
423 if (strcmp(ck, "identifier") == 0) {
424 char *name = cbm_node_text(a, child, ctx->source);
425 CBMImport imp = {.local_name = name, .module_path = path};
426 cbm_imports_push(&ctx->result->imports, a, imp);
427 found = true;
428 } else if (strcmp(ck, "import_clause") == 0) {
429 if (process_import_clause(ctx, child, path)) {
430 found = true;
431 }
432 }
433 }
434 if (!found) {
435 CBMImport imp = {.local_name = path_last(a, path), .module_path = path};
436 cbm_imports_push(&ctx->result->imports, a, imp);
437 }
438 return true;
439}
440
441/* Handle CommonJS `require("path")` call_expression nodes. The local name
442 * 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