MCPcopy Index your code
hub / github.com/bytebase/bytebase / skipHeadingSQLs

Function skipHeadingSQLs

backend/plugin/parser/tsql/completion.go:1679–1696  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

1677// skipHeadingSQLs skips the SQL statements which before the caret position.
1678// caretLine is 1-based and caretOffset is 0-based.
1679func 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
1698func statementIndexAtCaret(list []base.Statement, caretLine int, caretOffset int) int {
1699 for i, statement := range list {

Callers 1

computeSQLAndByteOffsetFunction · 0.70

Calls 5

statementIndexAtCaretFunction · 0.85
joinStatementTextsFunction · 0.85
SplitSQLFunction · 0.70

Tested by

no test coverage detected