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

Method getLineNumber

src/extraction/liquid-extractor.ts:519–531  ·  view source on GitHub ↗

* Get the line number for a character index

(index: number)

Source from the content-addressed store, hash-verified

517 * Get the line number for a character index
518 */
519 private getLineNumber(index: number): number {
520 // The line starts at or before the index: one more than the newlines before it.
521 const starts = this.lineStarts();
522 if (!(index > 0)) return 1;
523 let low = 0;
524 let high = starts.length;
525 while (low < high) {
526 const mid = (low + high) >> 1;
527 if (starts[mid]! <= index) low = mid + 1;
528 else high = mid;
529 }
530 return low;
531 }
532
533 /**
534 * Get the character index of the start of a line

Callers 5

extractSchemaMethod · 0.95
addVariableMethod · 0.95

Calls 1

lineStartsMethod · 0.95

Tested by

no test coverage detected