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

Function php_walk_blocks

internal/cbm/doclink_php.c:861–896  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

859}
860
861static void php_walk_blocks(php_walk_t *w, const TSNode *kids, int n, uint32_t file_last) {
862 int first_ns = CBM_NOT_FOUND;
863 for (int i = 0; i < n && first_ns < 0; i++) {
864 first_ns = php_kind(kids[i], "namespace_definition") ? i : first_ns;
865 }
866 if (first_ns < 0) {
867 w->blk = 0;
868 php_block(w, kids, 0, n);
869 return;
870 }
871 w->blk = CBM_NOT_FOUND;
872 for (int i = first_ns; i < n && !w->sb->oom; i++) {
873 if (!php_kind(kids[i], "namespace_definition")) {
874 continue;
875 }
876 w->blk++;
877 TSNode def = kids[i];
878 TSNode body = ts_node_child_by_field_name(def, TS_FIELD("body"));
879 uint32_t first = ts_node_start_point(def).row + SKIP_ONE;
880 if (!ts_node_is_null(body)) {
881 php_namespace_rec(w, def, first, ts_node_end_point(def).row + SKIP_ONE);
882 int bn = 0;
883 TSNode *bk = php_children(w, body, &bn);
884 php_block(w, bk, 0, bn);
885 continue;
886 }
887 int next = i + SKIP_ONE;
888 while (next < n && !php_kind(kids[next], "namespace_definition")) {
889 next++;
890 }
891 uint32_t last = next < n ? ts_node_start_point(kids[next]).row : file_last;
892 php_namespace_rec(w, def, first, last);
893 php_block(w, kids, i + SKIP_ONE, next);
894 i = next - SKIP_ONE;
895 }
896}
897
898const char *cbm_doclink_php_scan_scope(CBMExtractCtx *ctx) {
899 if (!ctx || ts_node_is_null(ctx->root)) {

Callers 1

Calls 4

php_kindFunction · 0.85
php_blockFunction · 0.85
php_namespace_recFunction · 0.85
php_childrenFunction · 0.85

Tested by

no test coverage detected