skipHeadingSQLs skips the SQL statements which before the caret position. caretLine is 1-based and caretOffset is 0-based.
(statement string, caretLine int, caretOffset int)
| 1677 | // skipHeadingSQLs skips the SQL statements which before the caret position. |
| 1678 | // caretLine is 1-based and caretOffset is 0-based. |
| 1679 | func skipHeadingSQLs(statement string, caretLine int, caretOffset int) (string, int, int) { |
| 1680 | list, err := SplitSQL(statement) |
| 1681 | if err != nil { |
| 1682 | return statement, caretLine, caretOffset |
| 1683 | } |
| 1684 | if !hasMultipleNonEmptyStatements(list) { |
| 1685 | return statement, caretLine, caretOffset |
| 1686 | } |
| 1687 | |
| 1688 | caretLineZeroBased := caretLine - 1 |
| 1689 | start := statementIndexAtCaret(list, caretLineZeroBased, caretOffset) |
| 1690 | if start == 0 { |
| 1691 | return statement, caretLine, caretOffset |
| 1692 | } |
| 1693 | |
| 1694 | newCaretLine, newCaretOffset := rebaseCaretAfterSkippedStatement(list[start-1], caretLineZeroBased, caretOffset) |
| 1695 | return joinStatementTexts(list[start:]), newCaretLine, newCaretOffset |
| 1696 | } |
| 1697 | |
| 1698 | func statementIndexAtCaret(list []base.Statement, caretLine int, caretOffset int) int { |
| 1699 | for i, statement := range list { |
no test coverage detected