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

Method findLineOffset

common/source.go:169–178  ·  view source on GitHub ↗

findLineOffset returns the offset where the (1-indexed) line begins, or false if line doesn't exist.

(line int)

Source from the content-addressed store, hash-verified

167// findLineOffset returns the offset where the (1-indexed) line begins,
168// or false if line doesn't exist.
169func (s *sourceImpl) findLineOffset(line int) (int32, bool) {
170 if line == 1 {
171 return 0, true
172 }
173 if line > 1 && line <= int(len(s.lineOffsets)) {
174 offset := s.lineOffsets[line-2]
175 return offset, true
176 }
177 return -1, false
178}
179
180// findLine finds the line that contains the given character offset and
181// returns the line number and offset of the beginning of that line.

Callers 2

LocationOffsetMethod · 0.95
SnippetMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected