return rewrite(var, filterExpr, statEnv);
} else if(srcExpr instanceof Variable) {
Variable var = (Variable) srcExpr;
return rewrite(var, filterExpr, statEnv);
} else if(srcExpr instanceof BDQExpr) {
final BDQExpr distExpr = (BDQExpr) srcExpr;
final XQExpression bodyExpr = distExpr.getBodyExpression();
if(bodyExpr instanceof PathVariable) {
PathVariable bodyVar = (PathVariable) bodyExpr;
CompositePath optExpr = new CompositePath(bodyVar, filterExpr);
distExpr.setBodyExpression(optExpr);
return distExpr;
} else {
AnonymousLetVariable wrappedVar = new AnonymousLetVariable(bodyExpr);
CompositePath optExpr = new CompositePath(wrappedVar, filterExpr);
distExpr.setBodyExpression(optExpr);
return distExpr;
}
}
return null;
}