MCPcopy Create free account
hub / github.com/ajitpratap0/GoSQLX / AdvanceN

Method AdvanceN

pkg/sql/tokenizer/position.go:120–136  ·  view source on GitHub ↗

AdvanceN moves the position forward by n bytes and recalculates the line and column numbers using the provided line start indices. This is used when jumping forward in the input (e.g., after skipping a comment block) where individual rune tracking would be inefficient. Parameters: - n: Number of b

(n int, lineStarts []int)

Source from the content-addressed store, hash-verified

118//
119// If n <= 0, this is a no-op.
120func (p *Position) AdvanceN(n int, lineStarts []int) {
121 if n <= 0 {
122 return
123 }
124
125 // Update index
126 p.Index += n
127
128 // Find which line we're on
129 for i := len(lineStarts) - 1; i >= 0; i-- {
130 if p.Index >= lineStarts[i] {
131 p.Line = i + 1
132 p.Column = p.Index - lineStarts[i] + 1
133 break
134 }
135 }
136}
137
138// Clone creates a copy of this Position.
139// The returned Position is independent and can be modified without

Callers 1

TestPosition_AdvanceNFunction · 0.95

Calls

no outgoing calls

Tested by 1

TestPosition_AdvanceNFunction · 0.76