MCPcopy Create free account
hub / github.com/brimdata/super / Position

Method Position

compiler/srcfiles/file.go:35–50  ·  view source on GitHub ↗
(pos int)

Source from the content-addressed store, hash-verified

33}
34
35func (f File) Position(pos int) Position {
36 if pos < 0 {
37 return Position{-1, -1, -1, -1}
38 }
39 offset := pos - f.start
40 i := searchLine(f.lines, offset)
41 if i < 0 {
42 return Position{-1, -1, -1, -1}
43 }
44 return Position{
45 Pos: pos,
46 Offset: offset,
47 Line: i + 1,
48 Column: offset - f.lines[i] + 1,
49 }
50}
51
52func (f File) LineOfPos(src string, pos int) string {
53 i := searchLine(f.lines, pos-f.start)

Callers 1

ErrorMethod · 0.45

Calls 1

searchLineFunction · 0.85

Tested by

no test coverage detected