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

Function pylsp_work_fixture

tests/test_py_lsp.c:2327–2360  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2325/* ── Suite ─────────────────────────────────────────────────────── */
2326
2327static char *pylsp_work_fixture(int n_classes, int *out_len) {
2328 /* Per class: ~140 chars (5-line def). Per call: ~50 chars. Overhead
2329 * for the class number digits scales with log10(n) but the constant
2330 * 256 covers up to 9-digit indices comfortably. */
2331 int approx = n_classes * 256 + 1024;
2332 char *buf = (char *)malloc((size_t)approx);
2333 if (!buf)
2334 return NULL;
2335 int pos = 0;
2336 pos += snprintf(buf + pos, (size_t)(approx - pos), "from typing import Self\n");
2337 for (int i = 0; i < n_classes; i++) {
2338 int n = snprintf(buf + pos, (size_t)(approx - pos),
2339 "class Cls%d:\n"
2340 " def method(self) -> int:\n"
2341 " return %d\n"
2342 " def chain(self) -> Self:\n"
2343 " return self\n",
2344 i, i);
2345 if (n < 0 || pos + n >= approx)
2346 break;
2347 pos += n;
2348 }
2349 int n = snprintf(buf + pos, (size_t)(approx - pos), "def use():\n");
2350 pos += n;
2351 for (int i = 0; i < n_classes; i++) {
2352 int m = snprintf(buf + pos, (size_t)(approx - pos),
2353 " Cls%d().chain().chain().method()\n", i);
2354 if (m < 0 || pos + m >= approx)
2355 break;
2356 pos += m;
2357 }
2358 *out_len = pos;
2359 return buf;
2360}
2361
2362/* Deterministic complexity gate (#1527, O9: no clock). The resolver
2363 * primitives count every candidate they examine -- scope-frame probes,

Callers 2

work_forFunction · 0.85
test_py_lsp.cFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected