// A single_valued_object_field is designated by the name of an association field in a
// one-to-one or many-to-one relationship or a field of embeddable class type
if (expression.hasIdentificationVariable() &&
!expression.endsWithDot()) {
IType type = getType(expression);
IMapping mapping = getMapping(expression);
// Does not resolve to a valid path
if (!type.isResolvable()) {
addProblem(expression, StateFieldPathExpression_NotResolvable, expression.toParsedText());
}
// Make sure an enum constant was parsed as a state field path
// expression before checking for a mapping
else if ((mapping == null) && type.isEnum()) {
String enumConstant = expression.getPath(expression.pathSize() - 1);
boolean found = false;
for (String constant : type.getEnumConstants()) {
if (constant.equals(enumConstant)) {
found = true;
break;
}
}
if (!found) {
int startIndex = position(expression) + type.getName().length() + 1;
int endIndex = startIndex + enumConstant.length();
addProblem(expression, startIndex, endIndex, StateFieldPathExpression_InvalidEnumConstant, enumConstant);
}
// Remove the used identification variable since it's is the first