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:2349–2371  ·  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

2347// Julia: a subtype declaration `Foo <: Bar` is a `binary_expression` (operator
2348// `<:`) inside the def's `type_head`. The base is the RHS identifier.
2349static const char **extract_julia_base_classes(CBMArena *a, TSNode node, const char *source) {
2350 TSNode th = cbm_find_child_by_kind(node, "type_head");
2351 if (ts_node_is_null(th)) {
2352 return NULL;
2353 }
2354 TSNode inner = ts_node_named_child_count(th) > 0 ? ts_node_named_child(th, 0) : th;
2355 if (ts_node_is_null(inner) || strcmp(ts_node_type(inner), "binary_expression") != 0 ||
2356 ts_node_named_child_count(inner) < 2) {
2357 return NULL;
2358 }
2359 TSNode base = ts_node_named_child(inner, ts_node_named_child_count(inner) - 1);
2360 char *bname = cbm_node_text(a, base, source);
2361 if (!bname || !bname[0]) {
2362 return NULL;
2363 }
2364 const char **result = (const char **)cbm_arena_alloc(a, 2 * sizeof(const char *));
2365 if (!result) {
2366 return NULL;
2367 }
2368 result[0] = bname;
2369 result[1] = NULL;
2370 return result;
2371}
2372
2373static const char **extract_base_classes(CBMArena *a, TSNode node, const char *source,
2374 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