int position = getPosition(expression);
//
// UPDATE clause
//
UpdateClause updateClause = expression.getUpdateClause();
int length = length(updateClause);
// Right after the UPDATE clause, the space is owned by the select statement
if ((position == length + SPACE_LENGTH) && expression.hasSpaceAfterUpdateClause()) {
virtualSpaces.add(SPACE_LENGTH);
corrections.add(-length - 2);
updateClause.accept(this);
corrections.pop();
virtualSpaces.pop();
}
// Nothing else to do
if ((position == length) && !expression.hasSpaceAfterUpdateClause()) {
return;
}
if (expression.hasSpaceAfterUpdateClause()) {
length++;
}
// Nothing else to do
if ((position == length) && !updateClause.hasRangeVariableDeclaration()) {
return;
}
//
// WHERE clause
//
// Right before "WHERE"
if (position == length) {
if (expression.hasSpaceAfterUpdateClause() &&
isComplete(updateClause.getUpdateItems())) {
addIdentifier(WHERE);
}
return;