diff --git a/src/autocomplete/databases/yql/yql-autocomplete.ts b/src/autocomplete/databases/yql/yql-autocomplete.ts index 04a71db9..9c060db7 100644 --- a/src/autocomplete/databases/yql/yql-autocomplete.ts +++ b/src/autocomplete/databases/yql/yql-autocomplete.ts @@ -32,7 +32,7 @@ import { ISymbolTableVisitor, ProcessVisitedRulesResult, } from '../../shared/autocomplete-types'; -import {ColumnAliasSymbol, TableSymbol} from '../../shared/symbol-table.js'; +import {ColumnAliasSymbol, ExtendedVariable, TableSymbol} from '../../shared/symbol-table.js'; import {TableQueryPosition} from '../../shared/tables'; import {isStartingToWriteRule} from '../../shared/cursor.js'; import {shouldSuggestTemplates} from '../../shared/query.js'; @@ -165,7 +165,7 @@ class YQLVariableSymbolTableVisitor extends YQLSymbolTableVisitor { const variable = getVariable(index); if (variable) { this.symbolTable.addNewSymbolOfType( - c3.VariableSymbol, + ExtendedVariable, this.scope, variable, variableValue, @@ -188,7 +188,7 @@ class YQLVariableSymbolTableVisitor extends YQLSymbolTableVisitor { if (variable) { const value = context.literal_value()?.getText(); - this.symbolTable.addNewSymbolOfType(c3.VariableSymbol, this.scope, variable, value); + this.symbolTable.addNewSymbolOfType(ExtendedVariable, this.scope, variable, value); } } catch (error) { if (!(error instanceof c3.DuplicateSymbolError)) { @@ -228,7 +228,7 @@ class YQLVariableSymbolTableVisitor extends YQLSymbolTableVisitor { const variable = context.bind_parameter()?.an_id_or_type()?.getText(); if (variable) { this.symbolTable.addNewSymbolOfType( - c3.VariableSymbol, + ExtendedVariable, this.scope, variable, undefined, diff --git a/src/autocomplete/shared/autocomplete-types.ts b/src/autocomplete/shared/autocomplete-types.ts index d87b5e9e..a74cfe80 100644 --- a/src/autocomplete/shared/autocomplete-types.ts +++ b/src/autocomplete/shared/autocomplete-types.ts @@ -74,7 +74,7 @@ export interface ColumnAliasSuggestion { export interface VariableSuggestion { name: string; - value: unknown; + value?: {columns?: string[]}; } export type LexerConstructor = new (input: CharStream) => T; diff --git a/src/autocomplete/shared/symbol-table.ts b/src/autocomplete/shared/symbol-table.ts index aefcbba7..e8f3190d 100644 --- a/src/autocomplete/shared/symbol-table.ts +++ b/src/autocomplete/shared/symbol-table.ts @@ -16,6 +16,10 @@ export class TableSymbol extends c3.TypedSymbol { } } +export class ExtendedVariable extends c3.VariableSymbol { + value: {columns?: string[]} | undefined; +} + export function getUniqueTableSuggestions(symbols: TableSymbol[] = []): Table[] { const suggestionsMap = symbols.reduce( (acc, table) => { diff --git a/src/autocomplete/shared/variables.ts b/src/autocomplete/shared/variables.ts index 56f02773..b3017d6c 100644 --- a/src/autocomplete/shared/variables.ts +++ b/src/autocomplete/shared/variables.ts @@ -9,7 +9,7 @@ import { SymbolTableVisitor, VariableSuggestion, } from './autocomplete-types'; -import {getScope} from './symbol-table'; +import {ExtendedVariable, getScope} from './symbol-table'; import {computeTokenContext} from './compute-token-position'; export function getVariableSuggestions( @@ -37,16 +37,16 @@ export function getVariableSuggestions !symbol.parent?.context); }