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

Method Snippet

common/source.go:155–165  ·  view source on GitHub ↗

Snippet implements the Source interface method.

(line int)

Source from the content-addressed store, hash-verified

153
154// Snippet implements the Source interface method.
155func (s *sourceImpl) Snippet(line int) (string, bool) {
156 charStart, found := s.findLineOffset(line)
157 if !found || s.Len() == 0 {
158 return "", false
159 }
160 charEnd, found := s.findLineOffset(line + 1)
161 if found {
162 return s.Slice(int(charStart), int(charEnd-1)), true
163 }
164 return s.Slice(int(charStart), s.Len()), true
165}
166
167// findLineOffset returns the offset where the (1-indexed) line begins,
168// or false if line doesn't exist.

Callers

nothing calls this directly

Calls 3

findLineOffsetMethod · 0.95
LenMethod · 0.65
SliceMethod · 0.65

Tested by

no test coverage detected