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

Function currentStatement

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

currentStatement returns the statement containing byte position pos within statement, along with pos translated to an offset within that statement. It uses omni's splitter so completion sees only the caret's statement, not table references from earlier statements in the buffer.

(statement string, pos int)

Source from the content-addressed store, hash-verified

547// uses omni's splitter so completion sees only the caret's statement, not table
548// references from earlier statements in the buffer.
549func currentStatement(statement string, pos int) (string, int) {
550 for _, seg := range tidbparser.Split(statement) {
551 if pos >= seg.ByteStart && pos <= seg.ByteEnd {
552 return seg.Text, pos - seg.ByteStart
553 }
554 }
555 return statement, pos
556}
557
558// omniCandidateTypeToBase maps omni TiDB completion candidate types to the
559// Bytebase base types. The six core types (keyword/database/table/view/column/

Callers 1

CompletionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected