MCPcopy Create free account
hub / github.com/bytebase/bytebase / lineColumnToByteOffset

Function lineColumnToByteOffset

backend/plugin/parser/mysql/completion.go:54–73  ·  view source on GitHub ↗
(sql string, line, column int)

Source from the content-addressed store, hash-verified

52}
53
54func lineColumnToByteOffset(sql string, line, column int) int {
55 currentLine := 1
56 for i := 0; i < len(sql); i++ {
57 if currentLine == line {
58 pos := i
59 for c := 0; c < column && pos < len(sql); c++ {
60 _, size := utf8.DecodeRuneInString(sql[pos:])
61 pos += size
62 }
63 if pos > len(sql) {
64 return len(sql)
65 }
66 return pos
67 }
68 if sql[i] == '\n' {
69 currentLine++
70 }
71 }
72 return len(sql)
73}
74
75func isNoSeparatorRequired(tokenType int) bool {
76 switch tokenType {

Callers 2

computeSQLAndByteOffsetFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected