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

Function php_use_clause

internal/cbm/doclink_php.c:508–542  ·  view source on GitHub ↗

One clause of a use declaration; `prefix` is a group's common prefix. */

Source from the content-addressed store, hash-verified

506
507/* One clause of a use declaration; `prefix` is a group's common prefix. */
508static void php_use_clause(php_walk_t *w, TSNode clause, char kind, const char *prefix,
509 size_t prefix_len) {
510 TSNode alias = ts_node_child_by_field_name(clause, TS_FIELD("alias"));
511 TSNode name = ts_node_named_child(clause, 0);
512 if (!php_kind(name, "name") && !php_kind(name, "qualified_name")) {
513 return;
514 }
515 size_t nl = 0;
516 const char *nt = php_name_text(w, name, &nl);
517 const char *full = nt;
518 size_t fl = nl;
519 if (prefix_len) {
520 char *joined =
521 cbm_arena_sprintf(w->sb->a, "%.*s\\%.*s", (int)prefix_len, prefix, (int)nl, nt);
522 if (!joined) {
523 w->sb->oom = true;
524 return;
525 }
526 full = joined;
527 fl = strlen(joined);
528 }
529 const char *al = NULL;
530 size_t all = 0;
531 if (!ts_node_is_null(alias)) {
532 al = php_name_text(w, alias, &all);
533 } else {
534 const char *bs = full + fl;
535 while (bs > full && bs[-SKIP_ONE] != '\\') {
536 bs--;
537 }
538 al = bs;
539 all = (size_t)(full + fl - bs);
540 }
541 php_add_use(w, php_use_kind(clause, kind), al, all, full, fl);
542}
543
544static void php_use_decl(php_walk_t *w, TSNode decl) {
545 char kind = php_use_kind(decl, 'c');

Callers 1

php_use_declFunction · 0.85

Calls 5

php_kindFunction · 0.85
php_name_textFunction · 0.85
php_add_useFunction · 0.85
cbm_arena_sprintfFunction · 0.70
php_use_kindFunction · 0.70

Tested by

no test coverage detected