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

Function makeLineAt

src/resolution/synth-utils.ts:20–37  ·  view source on GitHub ↗
(src: string, baseLine: number)

Source from the content-addressed store, hash-verified

18 * never produce a match — then answers each call with a binary search.
19 */
20export function makeLineAt(src: string, baseLine: number): (idx: number) => number {
21 let nl: number[] | null = null;
22 return (idx: number) => {
23 if (!nl) {
24 nl = [];
25 for (let i = src.indexOf('\n'); i !== -1; i = src.indexOf('\n', i + 1)) nl.push(i);
26 }
27 // Count newlines strictly before idx.
28 let lo = 0;
29 let hi = nl.length;
30 while (lo < hi) {
31 const mid = (lo + hi) >> 1;
32 if (nl[mid]! < idx) lo = mid + 1;
33 else hi = mid;
34 }
35 return baseLine + lo;
36 };
37}
38
39/** The last few long texts lineAt was asked about, each with its resolver; the most recent last. */
40const LINE_AT_TEXTS: Array<{ text: string; at: (idx: number) => number }> = [];

Callers 15

statedDefaultExportFunction · 0.90
readFactsFunction · 0.90
collectTestRequestsFunction · 0.90
svelteKitLinkEdgesFunction · 0.90
lineOfFunction · 0.90
closureCollectionEdgesFunction · 0.90
rnEventEdgesFunction · 0.90
objectRegistryEdgesFunction · 0.90
readRustFileFunction · 0.90
scanFileFunction · 0.90
reactRouterLinkEdgesFunction · 0.90
tanstackLinkEdgesFunction · 0.90

Calls 1

pushMethod · 0.80

Tested by

no test coverage detected