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:4232–4254  ·  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

4230// Julia: a subtype declaration `Foo <: Bar` is a `binary_expression` (operator
4231// `<:`) inside the def's `type_head`. The base is the RHS identifier.
4232static const char **extract_julia_base_classes(CBMArena *a, TSNode node, const char *source) {
4233 TSNode th = cbm_find_child_by_kind(node, "type_head");
4234 if (ts_node_is_null(th)) {
4235 return NULL;
4236 }
4237 TSNode inner = ts_node_named_child_count(th) > 0 ? ts_node_named_child(th, 0) : th;
4238 if (ts_node_is_null(inner) || strcmp(ts_node_type(inner), "binary_expression") != 0 ||
4239 ts_node_named_child_count(inner) < 2) {
4240 return NULL;
4241 }
4242 TSNode base = ts_node_named_child(inner, ts_node_named_child_count(inner) - 1);
4243 char *bname = cbm_node_text(a, base, source);
4244 if (!bname || !bname[0]) {
4245 return NULL;
4246 }
4247 const char **result = (const char **)cbm_arena_alloc(a, 2 * sizeof(const char *));
4248 if (!result) {
4249 return NULL;
4250 }
4251 result[0] = bname;
4252 result[1] = NULL;
4253 return result;
4254}
4255
4256static const char **extract_base_classes(CBMArena *a, TSNode node, const char *source,
4257 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