Class ExpressionSource
Operators are handed expressions as extracted TEXT, so by the time one is parsed nothing in the
AST knows where that text came from. SourcePosition therefore records only a
fragment-relative place (which keeps the by-text AST cache correct), and this class supplies the
origin to add back: the statement line the fragment starts on, and the column it starts at.
Scoped to the thread, like the statement clock, because a session's statements run on the
caller's thread. An expression evaluated with no origin set — a synthesised one, say, such as the
t.a that star-expansion invents and that never appeared in the source — reports no position
at all, which is the honest answer for text the user never wrote.
-
Method Summary
Modifier and TypeMethodDescriptionstatic SourcePositionbegin(SourcePosition origin) Note where the fragment about to be evaluated begins, returning whatever origin it displaced so a nested evaluation can put it back.static SourcePositionbeginNested(SourcePosition within) Note a fragment that lives INSIDE the fragment already in force, composing the two origins.static voidend(SourcePosition previous) Put back whateverbegin(dev.frostlake.executor.expressions.SourcePosition)displaced; null clears.static booleanWhether an origin is set — for callers that only build a message when one can be positioned.static SourcePositionresolve(SourcePosition withinFragment) The statement-relative place of a fragment-relative one, or null when no origin is set.
-
Method Details
-
begin
Note where the fragment about to be evaluated begins, returning whatever origin it displaced so a nested evaluation can put it back. -
beginNested
Note a fragment that lives INSIDE the fragment already in force, composing the two origins.Needed wherever a body is re-parsed from its own text and then walked item by item: a view's definition sits at some offset in the CREATE statement, and each select item sits at some offset in that definition, so a node's place in the STATEMENT is the two composed.
begin(dev.frostlake.executor.expressions.SourcePosition)replaces the origin outright, which is right for one level and silently wrong for two — the inner origin would win and the body's own offset would vanish.Composition is
resolve(dev.frostlake.executor.expressions.SourcePosition)'s arithmetic applied to the origin itself, so the line/column rule is stated in exactly one place: a fragment starting on the outer fragment's FIRST line is displaced by its column, one starting later keeps its own.- Parameters:
within- where the inner fragment begins, relative to the fragment currently in force- Returns:
- whatever origin it displaced, for
end(dev.frostlake.executor.expressions.SourcePosition)
-
end
Put back whateverbegin(dev.frostlake.executor.expressions.SourcePosition)displaced; null clears. -
resolve
The statement-relative place of a fragment-relative one, or null when no origin is set.A node on the fragment's FIRST line is offset by the origin's column; a node on a later line keeps its own column, because the origin's column only displaces the line it starts on.
-
hasOrigin
public static boolean hasOrigin()Whether an origin is set — for callers that only build a message when one can be positioned.
-