MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / buildSection

Method buildSection

src/mcp/tools.ts:3475–3497  ·  view source on GitHub ↗
(c: { start: number; end: number; hasSpine?: boolean; spineCallLine?: number })

Source from the content-addressed store, hash-verified

3473 const OVERSIZE_SPINE_LINES = 200;
3474 const SPINE_WINDOW = 28; // lines each side of the next-hop call site
3475 const buildSection = (c: { start: number; end: number; hasSpine?: boolean; spineCallLine?: number }): string => {
3476 if (c.hasSpine && c.spineCallLine && (c.end - c.start + 1) > OVERSIZE_SPINE_LINES) {
3477 const call = c.spineCallLine;
3478 const winStart = Math.max(c.start, call - SPINE_WINDOW);
3479 const winEnd = Math.min(c.end, call + SPINE_WINDOW);
3480 const parts: string[] = [];
3481 // Signature head, only when it sits clearly above the window (else the
3482 // window already covers the method opening).
3483 const headEnd = Math.min(c.start + 4, winStart - 2);
3484 if (headEnd >= c.start) {
3485 const head = fileLines.slice(c.start - 1, headEnd).join('\n');
3486 parts.push(withLineNumbers ? numberSourceLines(head, c.start) : head);
3487 }
3488 const win = fileLines.slice(winStart - 1, winEnd).join('\n');
3489 parts.push(withLineNumbers ? numberSourceLines(win, winStart) : win);
3490 return parts.join(GAP_MARKER);
3491 }
3492 const startIdx = Math.max(0, c.start - 1 - contextPadding);
3493 const endIdx = Math.min(fileLines.length, c.end + contextPadding);
3494 const slice = fileLines.slice(startIdx, endIdx).join('\n');
3495 // startIdx is 0-based, so the slice's first line is line startIdx + 1.
3496 return withLineNumbers ? numberSourceLines(slice, startIdx + 1) : slice;
3497 };
3498
3499 // Rank clusters for inclusion under the per-file cap. Entry-point
3500 // clusters come first: a cluster containing a query entry point

Callers

nothing calls this directly

Calls 2

numberSourceLinesFunction · 0.85
joinMethod · 0.45

Tested by

no test coverage detected