computeSQLAndByteOffset converts (statement, caretLine, caretOffset) to (trimmedSQL, byteOffset) for omni's parser.Collect API.
(statement string, caretLine int, caretOffset int, tricky bool)
| 41 | // computeSQLAndByteOffset converts (statement, caretLine, caretOffset) to |
| 42 | // (trimmedSQL, byteOffset) for omni's parser.Collect API. |
| 43 | func computeSQLAndByteOffset(statement string, caretLine int, caretOffset int, tricky bool) (string, int) { |
| 44 | var sql string |
| 45 | var newLine, newOffset int |
| 46 | if tricky { |
| 47 | sql, newLine, newOffset = skipHeadingSQLs(statement, caretLine, caretOffset) |
| 48 | sql, newLine, newOffset = skipHeadingSQLWithoutSemicolon(sql, newLine, newOffset) |
| 49 | } else { |
| 50 | sql, newLine, newOffset = skipHeadingSQLs(statement, caretLine, caretOffset) |
| 51 | } |
| 52 | return sql, lineColumnToByteOffset(sql, newLine, newOffset) |
| 53 | } |
| 54 | |
| 55 | // lineColumnToByteOffset converts 1-based line and 0-based column (character count) |
| 56 | // to a byte offset. Column is measured in runes (characters), not bytes, so that |
no test coverage detected