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

Function computeSQLAndByteOffset

backend/plugin/parser/pg/completion.go:43–53  ·  view source on GitHub ↗

computeSQLAndByteOffset converts (statement, caretLine, caretOffset) to (trimmedSQL, byteOffset) for omni's parser.Collect API.

(statement string, caretLine int, caretOffset int, tricky bool)

Source from the content-addressed store, hash-verified

41// computeSQLAndByteOffset converts (statement, caretLine, caretOffset) to
42// (trimmedSQL, byteOffset) for omni's parser.Collect API.
43func 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

Callers 2

NewTrickyCompleterFunction · 0.70
NewStandardCompleterFunction · 0.70

Calls 3

skipHeadingSQLsFunction · 0.70
lineColumnToByteOffsetFunction · 0.70

Tested by

no test coverage detected