Private API

These are private API methods. These are not intended for regular usage. It is not guaranteed that changes in functionality will be correctly reflected by changes in the module version numbers.

SQLAutocomplete

_getParser(tokens: CommonTokenStream): Parser

Retrieves the parser that will be used to identify tokens in the SQL string being autocompleted.

_tokenizeWhitespace()

Returns whether or not the current SQL dialect (and corresponding ANTLR4 grammar) tokenizes whitespace characters. If the grammar skips whitespace characters, this will return false. If the grammar parses whitespace characters (usually stored on the HIDDEN channel), then this will return true.

_getPreferredRulesForTable(): number[]

The ANTLR4 Code Completion Core (antlr4-c3) identifies possible autocompletion rules within the ANTLR4 grammar. It will return the keyword (and keep looking at child rules), unless that rule is within the preferred rule list. Preferred rules are returned separately from keywords by anltr4-c3. We use them to identify potential locations for tables and columns in our SQL.

This method returns the preferred rules that indicate a potential location where a table name or reference could be used in the SQL, for the current SQL dialect. The preferred rules are returned as an array of ID numbers, specific to the parser that was generated for the ANTLR4 grammar.

_getPreferredRulesForColumn(): number[]

The ANTLR4 Code Completion Core (antlr4-c3) identifies possible autocompletion rules within the ANTLR4 grammar. It will return the keyword (and keep looking at child rules), unless that rule is within the preferred rule list. Preferred rules are returned separately from keywords by anltr4-c3. We use them to identify potential locations for tables and columns in our SQL.

This method returns the preferred rules that indicate a potential location where a column name or reference could be used in the SQL, for the current SQL dialect. The preferred rules are returned as an array of ID numbers, specific to the parser that was generated for the ANTLR4 grammar.

_getTokensToIgnore(): number[]

Sometimes there are tokens that we don’t want to return for autocompletion. For example, suggesting an closing parenthesis ()) at any location in a SQL string after an opening parenthesis was used is not particularly helpful.

This method returns the list of tokens that we do not want included in autocompletion options returned by the ANTLR4 Code Completion Core (antlr4-c3), for the current SQL dialect. The tokens are returned as an array of ID numbers, specific to the parser that was generated for the ANTLR4 grammar.

_getTokenIndexAt(tokens: any[], fullString: string, offset: number): number

Get the token at the specified offset index within the fullString, from the array of tokens.

tokens: An array of Tokens, such as those returned by the SimpleSQLTokenizer

fullString: The full string of SQL being autocompleted.

offset: The index within the fullString that specifies where our desired token is located.

_getTokenString(token: any, fullString: string, offset: number): string

Get the text of the specified token. If the offset is less than the full length of the token, then the text will be concatenated to match the offset.

token: The Token that specifies the location within fullString where the

fullString: The full string of SQL being autocompleted.

offset: The index within the fullString that specifies where our desired token is located.