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

Function Completion

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

Completion returns auto-completion candidates for a Trino statement at the given caret position. It is backed by the omni Trino completer (github.com/bytebase/omni/trino/completion), which tokenizes the input up to the caret, classifies the completion context, and produces candidates from a three-le

(ctx context.Context, cCtx base.CompletionContext, statement string, caretLine int, caretOffset int)

Source from the content-addressed store, hash-verified

37// legacy completer's "every column in the default schema, ranked by priority".
38// Those fields are therefore left empty here.
39func Completion(ctx context.Context, cCtx base.CompletionContext, statement string, caretLine int, caretOffset int) ([]base.Candidate, error) {
40 cat := buildCompletionCatalog(ctx, cCtx, statement)
41
42 byteOffset := caretToByteOffset(statement, caretLine, caretOffset)
43 cands := completion.Complete(statement, byteOffset, cat)
44
45 result := make([]base.Candidate, 0, len(cands))
46 for _, c := range cands {
47 result = append(result, base.Candidate{
48 Text: c.Text,
49 Type: convertCandidateType(c.Type),
50 })
51 }
52 return result, nil
53}
54
55// buildCompletionCatalog constructs an omni Trino catalog from the completion
56// context's metadata. Each bytebase database becomes a Trino catalog; its

Callers 3

TestCompletionFunction · 0.70

Calls 3

buildCompletionCatalogFunction · 0.70
caretToByteOffsetFunction · 0.70
convertCandidateTypeFunction · 0.70

Tested by 3

TestCompletionFunction · 0.56