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

Function php_children

internal/cbm/doclink_php.c:434–455  ·  view source on GitHub ↗

All named children of a node, read with one cursor walk (indexing them is * quadratic). */

Source from the content-addressed store, hash-verified

432/* All named children of a node, read with one cursor walk (indexing them is
433 * quadratic). */
434static TSNode *php_children(php_walk_t *w, TSNode parent, int *count) {
435 *count = 0;
436 uint32_t nc = ts_node_named_child_count(parent);
437 if (nc == 0) {
438 return NULL;
439 }
440 TSNode *kids = (TSNode *)cbm_arena_alloc(w->sb->a, (size_t)nc * sizeof(TSNode));
441 if (!kids) {
442 w->sb->oom = true;
443 return NULL;
444 }
445 TSTreeCursor cur = ts_tree_cursor_new(parent);
446 for (bool more = ts_tree_cursor_goto_first_child(&cur); more && *count < (int)nc;
447 more = ts_tree_cursor_goto_next_sibling(&cur)) {
448 TSNode c = ts_tree_cursor_current_node(&cur);
449 if (ts_node_is_named(c)) {
450 kids[(*count)++] = c;
451 }
452 }
453 ts_tree_cursor_delete(&cur);
454 return kids;
455}
456
457/* `function` or `const` among a node's anonymous children: 'f', 'k', else
458 * `dflt`. */

Callers 10

php_use_declFunction · 0.85
php_basesFunction · 0.85
php_promotedFunction · 0.85
php_elementsFunction · 0.85
php_type_bodyFunction · 0.85
php_typeFunction · 0.85
php_cond_declsFunction · 0.85
php_count_namesFunction · 0.85
php_walk_blocksFunction · 0.85

Calls 1

cbm_arena_allocFunction · 0.70

Tested by

no test coverage detected