(sql string, line, column int)
| 508 | } |
| 509 | |
| 510 | func lineColumnToByteOffset(sql string, line, column int) int { |
| 511 | currentLine := 1 |
| 512 | for i := 0; i < len(sql); i++ { |
| 513 | if currentLine == line { |
| 514 | pos := i |
| 515 | for c := 0; c < column && pos < len(sql); c++ { |
| 516 | _, size := utf8.DecodeRuneInString(sql[pos:]) |
| 517 | pos += size |
| 518 | } |
| 519 | if pos > len(sql) { |
| 520 | return len(sql) |
| 521 | } |
| 522 | return pos |
| 523 | } |
| 524 | if sql[i] == '\n' { |
| 525 | currentLine++ |
| 526 | } |
| 527 | } |
| 528 | return len(sql) |
| 529 | } |
| 530 | |
| 531 | func findCaretTokenIndex(tokens []mssqlparser.Token, byteOffset int) int { |
| 532 | for i, tok := range tokens { |
no outgoing calls
no test coverage detected