rawsql-ts
Version:
[beta]High-performance SQL parser and AST analyzer written in TypeScript. Provides fast parsing and advanced transformation capabilities.
66 lines (65 loc) • 2.45 kB
TypeScript
/**
* Utility for caching keyword relationships for fast access
* Dynamically builds keyword relationships from existing joinkeywordParser
*
* SOURCE DICTIONARIES (single source of truth):
* - JOIN patterns: /src/tokenReaders/CommandTokenReader.ts (joinTrie, lines 10-29)
* - Command patterns: /src/tokenReaders/CommandTokenReader.ts (keywordTrie, lines 30-118)
*
* MIGRATION NOTE:
* If keywords are added/modified in CommandTokenReader.ts, update the
* extractCommandPatternsFromTrie() method to reflect those changes.
* JOIN patterns are automatically extracted via joinkeywordParser.
*/
export declare class KeywordCache {
private static joinSuggestionCache;
private static commandSuggestionCache;
private static initialized;
/**
* Initialize JOIN-related keyword suggestions
* Dynamically generated based on information extracted from joinkeywordParser
*/
private static initialize;
/**
* Get next suggestions for the specified keyword
* Example: "left" → ["join", "outer", "outer join"]
*/
static getJoinSuggestions(keyword: string): string[];
/**
* Check if a keyword is a valid JOIN keyword
* Uses existing joinkeywordParser as the primary resource
*/
static isValidJoinKeyword(keyword: string): boolean;
/**
* Generate suggestions based on partial keyword input
* Example: "le" → find keywords starting with "left"
*/
static getPartialSuggestions(partialKeyword: string): string[];
/**
* Get all JOIN keywords
*/
static getAllJoinKeywords(): string[];
/**
* Initialize command keyword patterns
* Dynamically extracted from commandKeywordTrie
*/
private static initializeCommandKeywords;
/**
* Extract multi-word patterns from commandKeywordTrie
* Uses known patterns since direct extraction from trie structure is difficult
*
* SOURCE: /src/tokenReaders/CommandTokenReader.ts keywordTrie (lines 30-118)
* MIGRATION: When updating, copy multi-word patterns from the source trie
*/
private static extractCommandPatternsFromTrie;
/**
* Get next command suggestions for the specified keyword
* Example: "group" → ["by"]
*/
static getCommandSuggestions(keyword: string): string[];
/**
* Force cache re-initialization
* Used for testing or when keyword definitions have changed
*/
static reset(): void;
}