GetLocationByOffset returns the line and column information for a given character offset.
(offset int32)
| 395 | |
| 396 | // GetLocationByOffset returns the line and column information for a given character offset. |
| 397 | func (s *SourceInfo) GetLocationByOffset(offset int32) common.Location { |
| 398 | line := 1 |
| 399 | col := int(offset) |
| 400 | for _, lineOffset := range s.LineOffsets() { |
| 401 | if lineOffset > offset { |
| 402 | break |
| 403 | } |
| 404 | line++ |
| 405 | col = int(offset - lineOffset) |
| 406 | } |
| 407 | return common.NewLocation(line, col) |
| 408 | } |
| 409 | |
| 410 | // ComputeOffset calculates the 0-based character offset from a 1-based line and 0-based column. |
| 411 | func (s *SourceInfo) ComputeOffset(line, col int32) int32 { |
no test coverage detected