Package dev.frostlake.executor
Class ParseTreeText
java.lang.Object
dev.frostlake.executor.ParseTreeText
Stateless helpers that read text and names out of ANTLR parse-tree nodes. Extracted from
QueryExecutor so query stages can share the same parse-tree text extraction without
depending on engine instance state — every method here is a pure function of its arguments.-
Method Summary
Modifier and TypeMethodDescriptionstatic StringextractStringLiteral(org.antlr.v4.runtime.tree.TerminalNode node) The plain (non-lambda) boolean-expression arguments of a function call.static String[]The canonical parts of a function's name, or null for a name that is a keyword or anIDENTIFIER(...); an empty middle part,db..f, is the database's PUBLIC schema.static StringThe canonical text of an ALIAS, which may be an ordinary identifier or one of the words legal only in a name position (CASE, CAST, CONSTRAINT, CROSS, DEFAULT, INNER, JOIN, WHEN).static Stringstatic StringgetIdentifier(org.antlr.v4.runtime.tree.TerminalNode node) static StringgetOriginalText(org.antlr.v4.runtime.ParserRuleContext ctx) static Stringstatic StringThe<name>.*flavour ofgetQualifiedName(dev.frostlake.parser.FrostlakeParser.QualifiedNameContext).static StringThe FROM-position flavour ofgetQualifiedName(dev.frostlake.parser.FrostlakeParser.QualifiedNameContext).Extract SelectClauseContext from a selectOperand (bare or parenthesised).Collect all top-level SelectClauseContexts from selectOperands (non-parenthesised ones).Get the whereClause of a selectClause, or null when absent.static booleanWhether a name leaves its middle part empty,db..t: it then has as many dots as written parts, where every other name has one dot fewer.static StringThe COLUMN-DEFINITION flavour — the same vocabulary less CONSTRAINT, which leads a constraint.static StringSeenamePartText(FrostlakeParser.NameStartPartContext)— the after-dot flavour.static StringThe canonical text of one name part: a regular identifier folds throughSqlIdentifiers.canonical(dev.frostlake.parser.FrostlakeParser.IdentifierContext); a keyword-as-name part (INNER, JOIN, LEFT, CROSS, CASE) is unquoted by construction and upper-cases directly.static Objectstatic String[]The name parts of a qualified name, read from the parse tree instead of splitting its flattened text on '.' — correct even for a quoted identifier containing a dot.static String[]The<name>.*flavour: astarQualifiedName's parts.static String[]The FROM-position flavour: atableQualifiedName's parts.static StringA star qualifier as written, with an empty middle part (db..t.*) spelled out as the PUBLIC schema it names; any other qualifier exactly as written.
-
Method Details
-
getWhereClause
public static FrostlakeParser.WhereClauseContext getWhereClause(FrostlakeParser.SelectClauseContext ctx) Get the whereClause of a selectClause, or null when absent. -
getSelectClause
public static FrostlakeParser.SelectClauseContext getSelectClause(FrostlakeParser.SelectOperandContext op) Extract SelectClauseContext from a selectOperand (bare or parenthesised). -
getSelectClauses
public static List<FrostlakeParser.SelectClauseContext> getSelectClauses(FrostlakeParser.SelectStatementContext ctx) Collect all top-level SelectClauseContexts from selectOperands (non-parenthesised ones). -
getIdentifier
-
getIdentifier
The canonical text of an ALIAS, which may be an ordinary identifier or one of the words legal only in a name position (CASE, CAST, CONSTRAINT, CROSS, DEFAULT, INNER, JOIN, WHEN). The keyword form is unquoted by construction, so it upper-cases directly — the same splitnamePartText(dev.frostlake.parser.FrostlakeParser.NameStartPartContext)makes. -
getQualifiedName
-
namePartText
The canonical text of one name part: a regular identifier folds throughSqlIdentifiers.canonical(dev.frostlake.parser.FrostlakeParser.IdentifierContext); a keyword-as-name part (INNER, JOIN, LEFT, CROSS, CASE) is unquoted by construction and upper-cases directly. -
namePartText
SeenamePartText(FrostlakeParser.NameStartPartContext)— the after-dot flavour. -
namePartText
The COLUMN-DEFINITION flavour — the same vocabulary less CONSTRAINT, which leads a constraint. -
qualifiedNameParts
The FROM-position flavour: atableQualifiedName's parts. -
getQualifiedName
The FROM-position flavour ofgetQualifiedName(dev.frostlake.parser.FrostlakeParser.QualifiedNameContext). -
qualifiedNameParts
The<name>.*flavour: astarQualifiedName's parts. -
getQualifiedName
The<name>.*flavour ofgetQualifiedName(dev.frostlake.parser.FrostlakeParser.QualifiedNameContext). -
qualifiedNameParts
The name parts of a qualified name, read from the parse tree instead of splitting its flattened text on '.' — correct even for a quoted identifier containing a dot. -
functionNameParts
The canonical parts of a function's name, or null for a name that is a keyword or anIDENTIFIER(...); an empty middle part,db..f, is the database's PUBLIC schema. -
writtenText
A star qualifier as written, with an empty middle part (db..t.*) spelled out as the PUBLIC schema it names; any other qualifier exactly as written. -
hasEmptySchemaPart
Whether a name leaves its middle part empty,db..t: it then has as many dots as written parts, where every other name has one dot fewer. -
functionBooleanArgs
public static List<FrostlakeParser.BooleanExprContext> functionBooleanArgs(FrostlakeParser.FunctionArgListContext list) The plain (non-lambda) boolean-expression arguments of a function call.functionArgListnow admits lambda arguments (for TRANSFORM/FILTER/REDUCE); aggregate/window/grouping call sites only ever have boolean-expression arguments, so this unwraps eachfunctionArgto itsbooleanExpr. -
getOriginalText
-
extractStringLiteral
-
getIdentifier
-
parseLiteral
-