Documentation
¶
Overview ¶
Package completion suggests completions for partially typed ClickHouse SQL.
The engine is a pure function of the input text, the cursor position and a metadata snapshot: it performs no I/O and can therefore run on every keystroke. It works on tokens rather than a parse tree because the input is by definition incomplete; see context.go for the heuristics.
Index ¶
Constants ¶
const MaxSuggestions = 500
MaxSuggestions caps the size of a result.
const WordSeparators = " \t\n\r!\"#%&'()*+,-./:;<=>?@[]^{|}~"
WordSeparators are the characters that end a completable word. The line editor re-derives the word being replaced from these, so suggestions must never contain one of them; names that would are not offered (see offerable).
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Engine ¶
type Engine struct {
Commands []MetaCommand
// OutputFormats are the client-side formats offered after FORMAT.
OutputFormats []string
}
Engine completes SQL and meta commands.
type Kind ¶
type Kind string
Kind says what a suggestion is.
const ( KindKeyword Kind = "keyword" KindDatabase Kind = "database" KindTable Kind = "table" KindView Kind = "view" KindDictionary Kind = "dictionary" KindColumn Kind = "column" KindAlias Kind = "alias" KindFunction Kind = "function" KindAggregate Kind = "aggregate function" KindTableFunction Kind = "table function" KindDataType Kind = "type" KindEngine Kind = "engine" KindFormat Kind = "format" KindSetting Kind = "setting" KindCommand Kind = "command" )
type MetaCommand ¶
MetaCommand describes a backslash command for completion purposes.
type Result ¶
type Result struct {
Suggestions []Suggestion
// Start is the byte offset of the word being completed; a chosen
// suggestion replaces input[Start:cursor].
Start int
}
Result is the outcome of a completion request.
type Suggestion ¶
type Suggestion struct {
// Text replaces the word being completed.
Text string
Kind Kind
// Detail is extra information for display, such as a column's type.
Detail string
}
Suggestion is one completion candidate.