MCPcopy Create free account
hub / github.com/cel-expr/cel-go / findLine

Method findLine

common/source.go:184–196  ·  view source on GitHub ↗

findLine finds the line that contains the given character offset and returns the line number and offset of the beginning of that line. Note that the last line is treated as if it contains all offsets beyond the end of the actual source.

(characterOffset int32)

Source from the content-addressed store, hash-verified

182// Note that the last line is treated as if it contains all offsets
183// beyond the end of the actual source.
184func (s *sourceImpl) findLine(characterOffset int32) (int32, int32) {
185 var line int32 = 1
186 for _, lineOffset := range s.lineOffsets {
187 if lineOffset > characterOffset {
188 break
189 }
190 line++
191 }
192 if line == 1 {
193 return line, 0
194 }
195 return line, s.lineOffsets[line-2]
196}

Callers 1

OffsetLocationMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected