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

Function extract_julia_base_classes

internal/cbm/extract_defs.c:2470–2492  ·  view source on GitHub ↗

Extract base class names from a class node. Julia: a subtype declaration `Foo <: Bar` is a `binary_expression` (operator `<:`) inside the def's `type_head`. The base is the RHS identifier.

Source from the content-addressed store, hash-verified

2468// Julia: a subtype declaration `Foo <: Bar` is a `binary_expression` (operator
2469// `<:`) inside the def's `type_head`. The base is the RHS identifier.
2470static const char **extract_julia_base_classes(CBMArena *a, TSNode node, const char *source) {
2471 TSNode th = cbm_find_child_by_kind(node, "type_head");
2472 if (ts_node_is_null(th)) {
2473 return NULL;
2474 }
2475 TSNode inner = ts_node_named_child_count(th) > 0 ? ts_node_named_child(th, 0) : th;
2476 if (ts_node_is_null(inner) || strcmp(ts_node_type(inner), "binary_expression") != 0 ||
2477 ts_node_named_child_count(inner) < 2) {
2478 return NULL;
2479 }
2480 TSNode base = ts_node_named_child(inner, ts_node_named_child_count(inner) - 1);
2481 char *bname = cbm_node_text(a, base, source);
2482 if (!bname || !bname[0]) {
2483 return NULL;
2484 }
2485 const char **result = (const char **)cbm_arena_alloc(a, 2 * sizeof(const char *));
2486 if (!result) {
2487 return NULL;
2488 }
2489 result[0] = bname;
2490 result[1] = NULL;
2491 return result;
2492}
2493
2494static const char **extract_base_classes(CBMArena *a, TSNode node, const char *source,
2495 CBMLanguage lang) {

Callers 1

extract_base_classesFunction · 0.85

Calls 3

cbm_find_child_by_kindFunction · 0.85
cbm_node_textFunction · 0.85
cbm_arena_allocFunction · 0.70

Tested by

no test coverage detected