Given some formula template of the form: “(SELECT … FROM A, B …)”
Line numbers reference Template.java on GitHub
Assume everything up to the FROM is rendered normally and without error. The following steps then occur.
result: "(SELECT ... "
token: "FROM"
inFromClause: false
beforeTable: false
afterFromTable: false
BEFORE_TABLE_KEYWORDS
contains "FROM"
, so conditional at line 311 changes state to
inFromClause: false -> true
beforeTable: false -> true
The token is then appended and the loop continues…
result: "(SELECT ... FROM"
token: " "
inFromClause: true
beforeTable: true
afterFromTable: false
The token is then appended and the loop continues…
result: "(SELECT ... FROM "
token: "A"
inFromClause: true
beforeTable: true
afterFromTable: false
beforeTable
is true, so the conditional branch at line 290 is executed, changing state to:
beforeTable: true -> false
afterFromTable: false -> true
The token is then appended and the loop continues…
result: "(SELECT ... FROM A"
token: ","
inFromClause: true
beforeTable: false
afterFromTable: true
afterFromTable
is true, so the conditional branch at 295 is executed <- This is what I believe to be a bug
The token is not "as"
, so the conditional branch at 296 is executed, changing state to:
afterFromTable: true -> false
The token is then appended and the loop continues…
result: "(SELECT ... FROM A,"
token: " "
inFromClause: true
beforeTable: false
afterFromTable: false
The token is then appended and the loop continues…
result: "(SELECT ... FROM A, "
token: "B"
inFromClause: true
beforeTable: false
afterFromTable: false
the token is a valid identifier, so the conditional branch at 304 is executed, appending the placeholder, a period, and the token
result: "(SELECT ... FROM A, $placeholder$.B"
However, there appears to be a conditional at line 315 intended to handle the case of a comma in a from clause, which would set beforeTable
to true, but because the conditional at line 295 matches that comma, beforeTable
never gets set to true.
It appears to me that either the conditional at line 315 is dead code, or that there is a bug in how the if/else chain is implemented.