(sql string, line, column int)
| 91 | } |
| 92 | |
| 93 | func lineColumnToByteOffset(sql string, line, column int) int { |
| 94 | currentLine := 1 |
| 95 | for i := 0; i < len(sql); i++ { |
| 96 | if currentLine == line { |
| 97 | pos := i |
| 98 | for c := 0; c < column && pos < len(sql); { |
| 99 | r, size := utf8.DecodeRuneInString(sql[pos:]) |
| 100 | if r == '\n' { |
| 101 | return pos |
| 102 | } |
| 103 | unitCount := 1 |
| 104 | if r > 0xFFFF { |
| 105 | unitCount = 2 |
| 106 | } |
| 107 | if c+unitCount > column { |
| 108 | return pos |
| 109 | } |
| 110 | pos += size |
| 111 | c += unitCount |
| 112 | } |
| 113 | if pos > len(sql) { |
| 114 | return len(sql) |
| 115 | } |
| 116 | return pos |
| 117 | } |
| 118 | if sql[i] == '\n' { |
| 119 | currentLine++ |
| 120 | } |
| 121 | } |
| 122 | return len(sql) |
| 123 | } |
| 124 | |
| 125 | func findCaretTokenIndex(tokens []oracleparser.Token, byteOffset int) int { |
| 126 | for i, tok := range tokens { |
no outgoing calls
no test coverage detected