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

Function process_import_clause

internal/cbm/extract_imports.c:375–405  ·  view source on GitHub ↗

Process an import_clause node: default, namespace, and named imports.

Source from the content-addressed store, hash-verified

373
374// Process an import_clause node: default, namespace, and named imports.
375static bool process_import_clause(CBMExtractCtx *ctx, TSNode clause, const char *path) {
376 CBMArena *a = ctx->arena;
377 bool found = false;
378 uint32_t cc = ts_node_child_count(clause);
379 for (uint32_t k = 0; k < cc; k++) {
380 TSNode sub = ts_node_child(clause, k);
381 const char *sk = ts_node_type(sub);
382 if (strcmp(sk, "identifier") == 0) {
383 char *name = cbm_node_text(a, sub, ctx->source);
384 CBMImport imp = {.local_name = name, .module_path = path};
385 cbm_imports_push(&ctx->result->imports, a, imp);
386 found = true;
387 } else if (strcmp(sk, "namespace_import") == 0) {
388 TSNode as_name = ts_node_child_by_field_name(sub, TS_FIELD("name"));
389 if (ts_node_is_null(as_name) && ts_node_child_count(sub) > 0) {
390 as_name = ts_node_child(sub, ts_node_child_count(sub) - SKIP_ONE);
391 }
392 if (!ts_node_is_null(as_name)) {
393 char *name = cbm_node_text(a, as_name, ctx->source);
394 CBMImport imp = {.local_name = name, .module_path = path};
395 cbm_imports_push(&ctx->result->imports, a, imp);
396 found = true;
397 }
398 } else if (strcmp(sk, "named_imports") == 0) {
399 if (process_named_imports(ctx, sub, path)) {
400 found = true;
401 }
402 }
403 }
404 return found;
405}
406
407/* Process a single ES import_statement node. Returns true if fully handled. */
408static bool process_es_import_statement(CBMExtractCtx *ctx, TSNode node) {

Callers 1

Calls 3

cbm_node_textFunction · 0.85
cbm_imports_pushFunction · 0.85
process_named_importsFunction · 0.85

Tested by

no test coverage detected