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

Function caretAtStatementStart

backend/plugin/parser/tidb/completion.go:408–416  ·  view source on GitHub ↗

caretAtStatementStart reports whether the caret is at a statement-start position — only whitespace and comments precede it (or it directly follows a ';'), ignoring any partial identifier the user is currently typing (so "CRE" or "...; INS" still count as statement start). Write keywords are filtered

(statement string, pos int)

Source from the content-addressed store, hash-verified

406// only here (in the query scene) so keywords valid inside read statements are
407// preserved in other positions.
408func caretAtStatementStart(statement string, pos int) bool {
409 if pos > len(statement) {
410 pos = len(statement)
411 }
412 before := stripStringsAndComments(statement)[:pos]
413 before = strings.TrimRight(before, identifierChars) // drop the partial identifier
414 before = strings.TrimRight(before, " \t\r\n")
415 return before == "" || before[len(before)-1] == ';'
416}
417
418func caretInsideBacktickIdentifier(statement string, pos int) bool {
419 if pos > len(statement) {

Callers 1

CompletionFunction · 0.85

Calls 1

stripStringsAndCommentsFunction · 0.85

Tested by

no test coverage detected