| 1062 | // import_declaration -> scoped_identifier |
| 1063 | |
| 1064 | static void parse_java_imports(CBMExtractCtx *ctx) { |
| 1065 | CBMArena *a = ctx->arena; |
| 1066 | |
| 1067 | TSTreeCursor cursor = ts_tree_cursor_new(ctx->root); |
| 1068 | if (!ts_tree_cursor_goto_first_child(&cursor)) { |
| 1069 | ts_tree_cursor_delete(&cursor); |
| 1070 | return; |
| 1071 | } |
| 1072 | do { |
| 1073 | TSNode node = ts_tree_cursor_current_node(&cursor); |
| 1074 | if (strcmp(ts_node_type(node), "import_declaration") != 0) { |
| 1075 | continue; |
| 1076 | } |
| 1077 | |
| 1078 | // Get the full import path (skip "import" and "static" keywords) |
| 1079 | uint32_t nc = ts_node_child_count(node); |
| 1080 | for (uint32_t j = 0; j < nc; j++) { |
| 1081 | TSNode child = ts_node_child(node, j); |
| 1082 | const char *ck = ts_node_type(child); |
| 1083 | if (strcmp(ck, "scoped_identifier") == 0 || strcmp(ck, "identifier") == 0) { |
| 1084 | char *path = cbm_node_text(a, child, ctx->source); |
| 1085 | if (path && path[0]) { |
| 1086 | CBMImport imp = {.local_name = path_last(a, path), .module_path = path}; |
| 1087 | cbm_imports_push(&ctx->result->imports, a, imp); |
| 1088 | } |
| 1089 | break; |
| 1090 | } |
| 1091 | } |
| 1092 | } while (ts_tree_cursor_goto_next_sibling(&cursor)); |
| 1093 | ts_tree_cursor_delete(&cursor); |
| 1094 | } |
| 1095 | |
| 1096 | // --- Rust imports --- |
| 1097 | // use_declaration -> use_list or scoped_use_list |
no test coverage detected