int startPosition = position(expression);
addProblem(expression, startPosition, InExpression_MissingExpression);
}
else {
Expression leftExpression = expression.getExpression();
JPQLQueryBNF queryBNF = getQueryBNF(expression.getExpressionExpressionQueryBNFId());
// First check for nested array support
if (isNestedArray(leftExpression)) {
if (!queryBNF.handlesNestedArray()) {
int startPosition = position(expression);
int endPosition = startPosition + length(leftExpression);
addProblem(expression, startPosition, endPosition, InExpression_InvalidExpression);
}
else {
leftExpression.accept(this);
}
}
// Validate the expression
else if (!isValid(leftExpression, queryBNF) || isDateTimeConstant(leftExpression)) {
int startPosition = position(expression);
int endPosition = startPosition + length(leftExpression);
addProblem(expression, startPosition, endPosition, InExpression_InvalidExpression);
}
else {
leftExpression.accept(this);
}
}
// Check for "IN :input_parameter" defined in JPA 2.0
boolean singleInputParameter = isNewerThanOrEqual(JPAVersion.VERSION_2_0) &&
expression.isSingleInputParameter();
// Missing '('
if (!expression.hasLeftParenthesis() && !singleInputParameter) {
int startPosition = position(expression) +
length(expression.getExpression()) +
(expression.hasExpression() ? 1 : 0) +
(expression.hasNot() ? 4 /* NOT + whitespace */ : 0) +
2 /* IN */;
addProblem(expression, startPosition, InExpression_MissingLeftParenthesis);
}
// There must be at least one element in the comma separated list that
// defines the set of values for the IN expression.
else if (!expression.hasInItems()) {
int startPosition = position(expression) +
length(expression.getExpression()) +
(expression.hasExpression() ? 1 : 0) +
(expression.hasNot() ? 4 /* NOT + whitespace */ : 0) +
2 /* IN */ +
(expression.hasSpaceAfterIn() ? 1 : 0) +
(expression.hasLeftParenthesis() ? 1 : 0);
addProblem(expression, startPosition, InExpression_MissingInItems);
}
// Make sure the IN items are separated by commas
else if (!singleInputParameter) {
Expression inItems = expression.getInItems();
CollectionExpression collectionExpression = getCollectionExpression(inItems);
// Validate the collection of items
if (collectionExpression != null) {
validateCollectionSeparatedByComma(
inItems,
InExpression_ItemEndsWithComma,
InExpression_ItemIsMissingComma
);
// Validate each item
JPQLQueryBNF queryBNF = getQueryBNF(expression.getExpressionItemQueryBNFId());
int index = 0;
for (Expression child : collectionExpression.children()) {
index++;
// First check for nested array support
if (isNestedArray(child)) {
if (!queryBNF.handlesNestedArray()) {
addProblem(child, InExpression_ItemInvalidExpression, String.valueOf(index));
}
else {
child.accept(this);
}