Defined in: packages/core/src/parsers/SelectQueryParser.ts:31
Legacy SELECT-only parser. Prefer using SqlParser as the canonical entry point for multi-statement or mixed-statement workflows.
Constructors
Constructor
new SelectQueryParser():
SelectQueryParser
Returns
SelectQueryParser
Methods
parse()
staticparse(query):SelectQuery
Defined in: packages/core/src/parsers/SelectQueryParser.ts:33
Parameters
query
string
Returns
analyze()
staticanalyze(query):ParseAnalysisResult
Defined in: packages/core/src/parsers/SelectQueryParser.ts:86
Parameters
query
string
Returns
parseAsync()
staticparseAsync(query):Promise<SelectQuery>
Defined in: packages/core/src/parsers/SelectQueryParser.ts:142
Asynchronously parse SQL string to AST. This method wraps the synchronous parse logic in a Promise for future extensibility.
Parameters
query
string
SQL string to parse
Returns
Promise<SelectQuery>
Promise<SelectQuery>
parseFromLexeme()
staticparseFromLexeme(lexemes,index):object
Defined in: packages/core/src/parsers/SelectQueryParser.ts:191
Parameters
lexemes
Lexeme[]
index
number
Returns
object
value
value:
SelectQuery
newIndex
newIndex:
number
getCursorCte()
staticgetCursorCte(sql,cursorPosition):null|string
Defined in: packages/core/src/parsers/SelectQueryParser.ts:631
Get the CTE name at the specified cursor position.
This method provides a simple interface for retrieving the CTE name based on a 1D cursor position in the SQL text.
Parameters
sql
string
The SQL string to analyze
cursorPosition
number
The cursor position (0-based character offset)
Returns
null | string
The CTE name if cursor is in a CTE, null otherwise
Deprecated
Use CTERegionDetector.getCursorCte() instead for better API consistency
Example
const sql = `WITH users AS (SELECT * FROM table) SELECT * FROM users`;
const cteName = SelectQueryParser.getCursorCte(sql, 25);
console.log(cteName); // "users"getCursorCteAt()
staticgetCursorCteAt(sql,line,column):null|string
Defined in: packages/core/src/parsers/SelectQueryParser.ts:654
Get the CTE name at the specified 2D coordinates (line, column).
This method provides a convenient interface for editor integrations that work with line/column coordinates instead of character positions.
Parameters
sql
string
The SQL string to analyze
line
number
The line number (1-based)
column
number
The column number (1-based)
Returns
null | string
The CTE name if cursor is in a CTE, null otherwise
Deprecated
Use CTERegionDetector.getCursorCteAt() instead for better API consistency
Example
const sql = `WITH users AS (\n SELECT * FROM table\n) SELECT * FROM users`;
const cteName = SelectQueryParser.getCursorCteAt(sql, 2, 5);
console.log(cteName); // "users"positionToLineColumn()
staticpositionToLineColumn(text,position):null| {line:number;column:number; }
Defined in: packages/core/src/parsers/SelectQueryParser.ts:666
Convert character position to line/column coordinates.
Parameters
text
string
The text to analyze
position
number
The character position (0-based)
Returns
null | { line: number; column: number; }
Object with line and column (1-based), or null if invalid position
Deprecated
Use CTERegionDetector.positionToLineColumn() instead for better API consistency