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.

This documentation is primarily provided for developers interested in contributing to SQL Surveyor.

SQLSurveyor

_getParser(tokens: CommonTokenStream): Parser

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

_getListener(sqlScript: string): BaseSqlQueryListener

Retrieves the listener that will be used to populate the ParsedSql object.

ParsedQuery

_getSubqueryAtLocation(stringIndex: number): ParsedQuery

Retrieves the subquery located at the zero-based index within the query, if it exists.

_getCommonTableExpressionAtLocation(stringIndex: number): ParsedQuery

Retrieves the common table expression located at the zero-based index within the query, if it exists.

_getParsedQueryIndexAtLocation(stringIndex: number, queries: { [queryStartIndex: number]: ParsedQuery }): number

From the provided queries, retrieves the zero-based index of the query key, located at the zero-based index.

_addAliasForTable(aliasName: string, tableName: string): void

Adds an alias to an existing referenced table on the query.

_addCommonTableExpression(parsedQuery: ParsedQuery): void

Adds the ParsedQuery to the array of common table expressions on this query.

_addOutputColumn(columnName: string, columnAlias: string, tableNameOrAlias: string): void

Adds a new output column to the ParsedQuery.

_addReferencedColumn(columnName: string, tableNameOrAlias: string, location: TokenLocation): void

If the referenced column does not exist, adds a new ReferencedColumn to this query. If the referenced column already exists, adds the location to it.

_addSubQuery(parsedQuery: ParsedQuery): void

Adds the ParsedQuery to the array of subqueries on this query.

_addTableNameLocation(tableName: string, location: TokenLocation, schemaName: string, databaseName: string): void

If the referenced table does not exist, adds a new ReferencedTable to this query. If the referenced table already exists, adds the location to it.

_addToken(location: TokenLocation, type: TokenType, token: string): void

Creates a token instance and adds the token to the array of tokens on this query.

_consolidateTables(): void

Aliases can be added to the ParsedQuery before the table itself. This method merges the aliases into the appropriate ReferencedTable.

_setCommonTableExpressionNames(): void

Set the common table expression names for any CTEs. Must be called after tokens have been added to the CTEs.

ParsedSql

_addQuery(parsedQuery: ParsedQuery): void

Adds the ParsedQuery to the array of queries on this object.

TokenTypeIdentifier

getTokenType(typeId: number): TokenType

The main entry point for the class. Identifies the token type that matches a provided typeId for the given SQL dialect and parser.

_getTSQLTokenType(typeId: number): TokenType

Determines the token type based on heuristics for the T-SQL tokens.

_getPLSQLTokenType(typeId: number): TokenType

Determines the token type based on heuristics for the PL/SQL tokens.

_getPLpgSQLTokenType(typeId: number): TokenType

Determines the token type based on heuristics for the PL/pgSQL tokens.

_getMYSQLTokenType(typeId: number): TokenType

Determines the token type based on heuristics for the MySQL tokens.