Try known field names (path/source/module/name) to extract import path.
| 1439 | |
| 1440 | // Try known field names (path/source/module/name) to extract import path. |
| 1441 | static bool try_generic_path_fields(CBMExtractCtx *ctx, TSNode node) { |
| 1442 | CBMArena *a = ctx->arena; |
| 1443 | static const char *path_fields[] = {"path", "source", "module", "name", NULL}; |
| 1444 | for (const char **f = path_fields; *f; f++) { |
| 1445 | TSNode path_node = ts_node_child_by_field_name(node, *f, (uint32_t)strlen(*f)); |
| 1446 | if (!ts_node_is_null(path_node)) { |
| 1447 | char *path = strip_quotes(a, cbm_node_text(a, path_node, ctx->source)); |
| 1448 | if (path && path[0]) { |
| 1449 | CBMImport imp = {.local_name = path_last(a, path), .module_path = path}; |
| 1450 | cbm_imports_push(&ctx->result->imports, a, imp); |
| 1451 | } |
| 1452 | return true; |
| 1453 | } |
| 1454 | } |
| 1455 | return false; |
| 1456 | } |
| 1457 | |
| 1458 | // Fallback: extract import path from full node text, stripping keyword and semicolon. |
| 1459 | static void generic_import_from_text(CBMExtractCtx *ctx, TSNode node) { |
no test coverage detected