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

Method ComputeOffset

common/ast/ast.go:419–425  ·  view source on GitHub ↗

ComputeOffset calculates the 0-based character offset from a 1-based line and 0-based column.

(line, col int32)

Source from the content-addressed store, hash-verified

417
418// ComputeOffset calculates the 0-based character offset from a 1-based line and 0-based column.
419func (s *SourceInfo) ComputeOffset(line, col int32) int32 {
420 if s != nil {
421 line = s.baseLine + line
422 col = s.baseCol + col
423 }
424 return s.ComputeOffsetAbsolute(line, col)
425}
426
427// ComputeOffsetAbsolute calculates the 0-based character offset from a 1-based line and 0-based column
428// based on the absolute line and column of the SourceInfo.

Callers 5

TestSourceInfoFunction · 0.95
idMethod · 0.80
SyntaxErrorMethod · 0.80
TestSourceInfoNilSafetyFunction · 0.80

Calls 1

ComputeOffsetAbsoluteMethod · 0.95

Tested by 3

TestSourceInfoFunction · 0.76
TestSourceInfoNilSafetyFunction · 0.64