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

Function parse_java_imports

internal/cbm/extract_imports.c:555–585  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

553// import_declaration -> scoped_identifier
554
555static void parse_java_imports(CBMExtractCtx *ctx) {
556 CBMArena *a = ctx->arena;
557
558 TSTreeCursor cursor = ts_tree_cursor_new(ctx->root);
559 if (!ts_tree_cursor_goto_first_child(&cursor)) {
560 ts_tree_cursor_delete(&cursor);
561 return;
562 }
563 do {
564 TSNode node = ts_tree_cursor_current_node(&cursor);
565 if (strcmp(ts_node_type(node), "import_declaration") != 0) {
566 continue;
567 }
568
569 // Get the full import path (skip "import" and "static" keywords)
570 uint32_t nc = ts_node_child_count(node);
571 for (uint32_t j = 0; j < nc; j++) {
572 TSNode child = ts_node_child(node, j);
573 const char *ck = ts_node_type(child);
574 if (strcmp(ck, "scoped_identifier") == 0 || strcmp(ck, "identifier") == 0) {
575 char *path = cbm_node_text(a, child, ctx->source);
576 if (path && path[0]) {
577 CBMImport imp = {.local_name = path_last(a, path), .module_path = path};
578 cbm_imports_push(&ctx->result->imports, a, imp);
579 }
580 break;
581 }
582 }
583 } while (ts_tree_cursor_goto_next_sibling(&cursor));
584 ts_tree_cursor_delete(&cursor);
585}
586
587// --- Rust imports ---
588// 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