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

Method buildSection

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

Source from the content-addressed store, hash-verified

3626 const OVERSIZE_SPINE_LINES = 200;
3627 const SPINE_WINDOW = 28; // lines each side of the next-hop call site
3628 const buildSection = (c: { start: number; end: number; hasSpine?: boolean; spineCallLine?: number }): string => {
3629 if (c.hasSpine && c.spineCallLine && (c.end - c.start + 1) > OVERSIZE_SPINE_LINES) {
3630 const call = c.spineCallLine;
3631 const winStart = Math.max(c.start, call - SPINE_WINDOW);
3632 const winEnd = Math.min(c.end, call + SPINE_WINDOW);
3633 const parts: string[] = [];
3634 // Signature head, only when it sits clearly above the window (else the
3635 // window already covers the method opening).
3636 const headEnd = Math.min(c.start + 4, winStart - 2);
3637 if (headEnd >= c.start) {
3638 const head = fileLines.slice(c.start - 1, headEnd).join('\n');
3639 parts.push(withLineNumbers ? numberSourceLines(head, c.start) : head);
3640 }
3641 const win = fileLines.slice(winStart - 1, winEnd).join('\n');
3642 parts.push(withLineNumbers ? numberSourceLines(win, winStart) : win);
3643 return parts.join(GAP_MARKER);
3644 }
3645 const startIdx = Math.max(0, c.start - 1 - contextPadding);
3646 const endIdx = Math.min(fileLines.length, c.end + contextPadding);
3647 const slice = fileLines.slice(startIdx, endIdx).join('\n');
3648 // startIdx is 0-based, so the slice's first line is line startIdx + 1.
3649 return withLineNumbers ? numberSourceLines(slice, startIdx + 1) : slice;
3650 };
3651
3652 // Rank clusters for inclusion under the per-file cap. Entry-point
3653 // 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