findCaretTokenIndex returns the index of the first token whose start (Loc) is at or past byteOffset. This matches ANTLR Scanner.SeekPosition semantics: the caret token is the one that starts at or after the cursor position. Uses >= so that when the cursor is exactly at a token boundary, we pick that
(tokens []pgparser.Token, byteOffset int)
| 178 | // that token (not the one before it). |
| 179 | // Returns len(tokens) if all tokens are before byteOffset. |
| 180 | func findCaretTokenIndex(tokens []pgparser.Token, byteOffset int) int { |
| 181 | for i, tok := range tokens { |
| 182 | if tok.Loc >= byteOffset { |
| 183 | return i |
| 184 | } |
| 185 | } |
| 186 | return len(tokens) |
| 187 | } |
| 188 | |
| 189 | func (c *Completer) completion() ([]base.Candidate, error) { |
| 190 | // Check if the caret token is quoted. |
no outgoing calls
no test coverage detected