final Map<String, String> tokenCaseSensitive = new HashMap<String, String>();
public TokenCompletor(Catalog catalog) throws Exception {
this.catalog = catalog;
Database catalog_db = CatalogUtil.getDatabase(catalog);
// Core SQL Reserved Words from HSQLDB
for (int i = 0; i < 1000; i++) {
if (Tokens.isCoreKeyword(i)) {
String keyword = Tokens.getKeyword(i);
if (keyword != null) this.sqlTokens.add(keyword);
}
} // FOR
// Special command tokens
for (QueryType qtype : QueryType.values()) {
if (qtype == QueryType.INVALID || qtype == QueryType.NOOP) continue;
this.commandTokens.add(qtype.name());
} // FOR
for (HStoreTerminal.Command c : HStoreTerminal.Command.values()) {
this.commandTokens.add(c.name());
this.specialTokens.add(c.name());
} // FOR
// Catalog Keywords
// Tables, columns, procedures names
CollectionUtil.addAll(this.tablePrefixes, TABLE_PREFIXES);
CollectionUtil.addAll(this.columnPrefixes, COLUMN_PREFIXES);
for (Table catalog_tbl : CatalogUtil.getDataTables(catalog_db)) {
this.tableTokens.add(catalog_tbl.getName());
this.columnPrefixes.add(catalog_tbl.getName() + ".");
for (Column catalog_col : catalog_tbl.getColumns()) {
this.columnTokens.add(catalog_col.getName().toUpperCase());
} // FOR
} // FOR
CollectionUtil.addAll(this.procPrefixes, PROC_PREFIXES);
for (Procedure catalog_proc : catalog_db.getProcedures()) {
String procName = catalog_proc.getName().toUpperCase();
this.tokenCaseSensitive.put(procName, catalog_proc.getName());
this.procTokens.add(procName);
} // FOR