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

Method ComputeOffset

common/ast/ast.go:411–417  ·  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

409
410// ComputeOffset calculates the 0-based character offset from a 1-based line and 0-based column.
411func (s *SourceInfo) ComputeOffset(line, col int32) int32 {
412 if s != nil {
413 line = s.baseLine + line
414 col = s.baseCol + col
415 }
416 return s.ComputeOffsetAbsolute(line, col)
417}
418
419// ComputeOffsetAbsolute calculates the 0-based character offset from a 1-based line and 0-based column
420// 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