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

Function parse_java_imports

internal/cbm/extract_imports.c:1064–1094  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1062// import_declaration -> scoped_identifier
1063
1064static 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

Callers 1

cbm_extract_importsFunction · 0.85

Calls 3

cbm_node_textFunction · 0.85
path_lastFunction · 0.85
cbm_imports_pushFunction · 0.85

Tested by

no test coverage detected