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

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

Source from the content-addressed store, hash-verified

915
916/* Process a single ES import_statement node. Returns true if fully handled. */
917static bool process_es_import_statement(CBMExtractCtx *ctx, TSNode node) {
918 CBMArena *a = ctx->arena;
919 TSNode source_node = find_es_source_node(node);
920 if (ts_node_is_null(source_node)) {
921 return false;
922 }
923 char *path = strip_quotes(a, cbm_node_text(a, source_node, ctx->source));
924 if (!path || !path[0]) {
925 return false;
926 }
927 uint32_t nc = ts_node_child_count(node);
928 bool found = false;
929 for (uint32_t j = 0; j < nc; j++) {
930 TSNode child = ts_node_child(node, j);
931 const char *ck = ts_node_type(child);
932 if (strcmp(ck, "identifier") == 0) {
933 char *name = cbm_node_text(a, child, ctx->source);
934 CBMImport imp = {.local_name = name, .module_path = path};
935 cbm_imports_push(&ctx->result->imports, a, imp);
936 found = true;
937 } else if (strcmp(ck, "import_clause") == 0) {
938 if (process_import_clause(ctx, child, path)) {
939 found = true;
940 }
941 }
942 }
943 if (!found) {
944 CBMImport imp = {.local_name = path_last(a, path), .module_path = path};
945 cbm_imports_push(&ctx->result->imports, a, imp);
946 }
947 return true;
948}
949
950/* Handle CommonJS `require("path")` call_expression nodes. The local name
951 * 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