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

Function php_lsp_add_use

internal/cbm/lsp/php_lsp.c:156–182  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

154}
155
156void php_lsp_add_use(PHPLSPContext *ctx, const char *local_name, const char *target_qn,
157 int use_kind) {
158 if (!local_name || !target_qn)
159 return;
160 if (ctx->use_count >= ctx->use_cap) {
161 int new_cap = ctx->use_cap ? ctx->use_cap * 2 : PHP_USE_INITIAL_CAP;
162 const char **nl = (const char **)cbm_arena_alloc(ctx->arena, (size_t)new_cap * sizeof(*nl));
163 const char **nq = (const char **)cbm_arena_alloc(ctx->arena, (size_t)new_cap * sizeof(*nq));
164 int *nk = (int *)cbm_arena_alloc(ctx->arena, (size_t)new_cap * sizeof(int));
165 if (!nl || !nq || !nk)
166 return;
167 for (int i = 0; i < ctx->use_count; i++) {
168 nl[i] = ctx->use_local_names[i];
169 nq[i] = ctx->use_target_qns[i];
170 nk[i] = (int)ctx->use_kinds[i];
171 }
172 ctx->use_local_names = nl;
173 ctx->use_target_qns = nq;
174 /* re-cast to the enum-typed pointer */
175 ctx->use_kinds = (void *)nk;
176 ctx->use_cap = new_cap;
177 }
178 ctx->use_local_names[ctx->use_count] = cbm_arena_strdup(ctx->arena, local_name);
179 ctx->use_target_qns[ctx->use_count] = cbm_arena_strdup(ctx->arena, target_qn);
180 ((int *)ctx->use_kinds)[ctx->use_count] = use_kind;
181 ctx->use_count++;
182}
183
184static const char *find_use(PHPLSPContext *ctx, const char *local_name, int kind) {
185 for (int i = 0; i < ctx->use_count; i++) {

Callers 2

collect_use_clauseFunction · 0.85

Calls 2

cbm_arena_allocFunction · 0.50
cbm_arena_strdupFunction · 0.50

Tested by

no test coverage detected