| 196 | } |
| 197 | |
| 198 | func (c *Completer) prefixToken() (mysqlparser.Token, bool) { |
| 199 | idx := c.caretTokenIndex |
| 200 | if idx < len(c.tokens) { |
| 201 | tok := c.tokens[idx] |
| 202 | if tok.Loc < c.cursorByteOffset && c.cursorByteOffset <= tok.End && mysqlparser.IsIdentTokenType(tok.Type) { |
| 203 | return tok, true |
| 204 | } |
| 205 | } |
| 206 | if idx > 0 { |
| 207 | tok := c.tokens[idx-1] |
| 208 | if tok.End == c.cursorByteOffset && mysqlparser.IsIdentTokenType(tok.Type) { |
| 209 | return tok, true |
| 210 | } |
| 211 | } |
| 212 | return mysqlparser.Token{}, false |
| 213 | } |
| 214 | |
| 215 | type CompletionMap map[string]base.Candidate |
| 216 | |