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

Method computeOffset

parser/helper.go:158–165  ·  view source on GitHub ↗

computeOffset converts a 0-based character offset from the local source content to the corresponding absolute character offset in the parent SourceInfo (e.g. for RelativeSource). If the location cannot be resolved or the source is nil, the original offset is returned.

(offset int32)

Source from the content-addressed store, hash-verified

156// the corresponding absolute character offset in the parent SourceInfo (e.g. for RelativeSource).
157// If the location cannot be resolved or the source is nil, the original offset is returned.
158func (p *parserHelper) computeOffset(offset int32) int32 {
159 if p.source != nil {
160 if loc, found := p.source.OffsetLocation(offset); found {
161 return p.sourceInfo.ComputeOffsetAbsolute(int32(loc.Line()), int32(loc.Column()))
162 }
163 }
164 return offset
165}
166
167func (p *parserHelper) id(ctx any) int64 {
168 var offset ast.OffsetRange

Callers 3

idMethod · 0.95
idFromOffsetsMethod · 0.95
setTokenLocationMethod · 0.95

Calls 4

ComputeOffsetAbsoluteMethod · 0.80
OffsetLocationMethod · 0.65
LineMethod · 0.65
ColumnMethod · 0.65

Tested by

no test coverage detected