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

Method ComputeOffsetAbsolute

common/ast/ast.go:421–430  ·  view source on GitHub ↗

ComputeOffsetAbsolute calculates the 0-based character offset from a 1-based line and 0-based column based on the absolute line and column of the SourceInfo.

(line, col int32)

Source from the content-addressed store, hash-verified

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.
421func (s *SourceInfo) ComputeOffsetAbsolute(line, col int32) int32 {
422 if line == 1 {
423 return col
424 }
425 if line < 1 || line > int32(len(s.LineOffsets())) {
426 return -1
427 }
428 offset := s.LineOffsets()[line-2]
429 return offset + col
430}
431
432// Extensions returns the set of extensions present in the source.
433func (s *SourceInfo) Extensions() []Extension {

Callers 2

ComputeOffsetMethod · 0.95
idMethod · 0.80

Calls 1

LineOffsetsMethod · 0.95

Tested by

no test coverage detected