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

Method completion

backend/plugin/parser/plsql/completion.go:134–170  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

132}
133
134func (c *Completer) completion() ([]base.Candidate, error) {
135 checkTokenQuoted := func(idx int) bool {
136 if idx < 0 || idx >= len(c.tokens) {
137 return false
138 }
139 tok := c.tokens[idx]
140 return tok.Loc < len(c.sql) && c.sql[tok.Loc] == '"'
141 }
142 if checkTokenQuoted(c.caretTokenIndex) {
143 c.caretTokenIsQuoted = true
144 } else if c.caretTokenIndex > 0 {
145 prev := c.tokens[c.caretTokenIndex-1]
146 if prev.End >= c.cursorByteOffset && checkTokenQuoted(c.caretTokenIndex-1) {
147 c.caretTokenIsQuoted = true
148 }
149 }
150
151 if c.querySceneDisallowsCompletion() {
152 return nil, nil
153 }
154
155 completionContext := oracleparser.CollectCompletion(c.sql, c.cursorByteOffset)
156 if completionContext != nil {
157 c.completionPrefix = completionContext.Prefix
158 c.completionIntent = completionContext.Intent
159 c.collectCompletionCTEs(completionContext)
160 c.collectCompletionScopeReferences(completionContext)
161 }
162 candidates := (*oracleparser.CandidateSet)(nil)
163 if completionContext != nil {
164 candidates = completionContext.Candidates
165 }
166 if candidates == nil {
167 candidates = oracleparser.Collect(c.sql, c.cursorByteOffset)
168 }
169 return c.filterCandidatesByScene(c.convertCandidates(candidates)), nil
170}
171
172type CompletionMap map[string]base.Candidate
173

Callers 1

CompletionFunction · 0.45

Tested by

no test coverage detected