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

Function process_import_clause

internal/cbm/extract_imports.c:364–394  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

362
363// Process an import_clause node: default, namespace, and named imports.
364static bool process_import_clause(CBMExtractCtx *ctx, TSNode clause, const char *path) {
365 CBMArena *a = ctx->arena;
366 bool found = false;
367 uint32_t cc = ts_node_child_count(clause);
368 for (uint32_t k = 0; k < cc; k++) {
369 TSNode sub = ts_node_child(clause, k);
370 const char *sk = ts_node_type(sub);
371 if (strcmp(sk, "identifier") == 0) {
372 char *name = cbm_node_text(a, sub, ctx->source);
373 CBMImport imp = {.local_name = name, .module_path = path};
374 cbm_imports_push(&ctx->result->imports, a, imp);
375 found = true;
376 } else if (strcmp(sk, "namespace_import") == 0) {
377 TSNode as_name = ts_node_child_by_field_name(sub, TS_FIELD("name"));
378 if (ts_node_is_null(as_name) && ts_node_child_count(sub) > 0) {
379 as_name = ts_node_child(sub, ts_node_child_count(sub) - SKIP_ONE);
380 }
381 if (!ts_node_is_null(as_name)) {
382 char *name = cbm_node_text(a, as_name, ctx->source);
383 CBMImport imp = {.local_name = name, .module_path = path};
384 cbm_imports_push(&ctx->result->imports, a, imp);
385 found = true;
386 }
387 } else if (strcmp(sk, "named_imports") == 0) {
388 if (process_named_imports(ctx, sub, path)) {
389 found = true;
390 }
391 }
392 }
393 return found;
394}
395
396/* Process a single ES import_statement node. Returns true if fully handled. */
397static 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