protected void visitPathExpression(AbstractPathExpression expression, Filter<IMapping> filter) {
MappingCollector mappingCollector = getDefaultMappingCollector();
int position = queryPosition.getPosition(expression);
boolean mappingCollectorCreated = false;
Resolver resolver = null;
int length = 0;
for (int index = 0, count = expression.pathSize(); index < count; index++) {
String path = expression.getPath(index);
// We're at the position, create the ChoiceBuilder
if (position <= length + path.length()) {
if (length == position) {
path = ExpressionTools.EMPTY_STRING;
}
else if (position - length > -1) {
path = path.substring(0, position - length);
}
// Special case where the path expression only has the
// identification variable set
if (resolver == null) {
break;
}
mappingCollector = buildFilteringMappingCollector(expression, resolver, filter, path);
mappingCollectorCreated = true;
break;
}
// The path is entirely before the position of the cursor
else {
// The first path is always an identification variable
if (resolver == null) {
resolver = queryContext.getResolver(expression.getIdentificationVariable());
}
// Any other path is a property or collection-valued path
else if ((index + 1 < count) || expression.endsWithDot()) {
Resolver childResolver = resolver.getChild(path);
if (childResolver == null) {
childResolver = new StateFieldResolver(resolver, path);
resolver.addChild(path, childResolver);
resolver = childResolver;
}