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

Method ComputeOffsetAbsolute

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

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.
429func (s *SourceInfo) ComputeOffsetAbsolute(line, col int32) int32 {
430 if line == 1 {
431 return col
432 }
433 if line < 1 || line > int32(len(s.LineOffsets())) {
434 return -1
435 }
436 offset := s.LineOffsets()[line-2]
437 return offset + col
438}
439
440// Extensions returns the set of extensions present in the source.
441func (s *SourceInfo) Extensions() []Extension {

Callers 2

ComputeOffsetMethod · 0.95
idMethod · 0.80

Calls 1

LineOffsetsMethod · 0.95

Tested by

no test coverage detected