()
| 132 | } |
| 133 | |
| 134 | func (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 | |
| 172 | type CompletionMap map[string]base.Candidate |
| 173 |
no test coverage detected