@Override
public Object visitPropertyCallExp(
PropertyCallExp<EClassifier, EStructuralFeature> pc) {
// special behavior in LHS mode for outermost expression
if (pc.eContainer() == null) {
// evaluate source
OCLExpression<EClassifier> source = pc.getSource();
EObject context = (EObject) source.accept(getVisitor());
return new Pair<EStructuralFeature, List<EObject>>(
pc.getReferredProperty(),
Arrays.asList(new EObject[] { context }));
}
// regular processing
return super.visitPropertyCallExp(pc);
}
@Override
public Object visitIteratorExp(IteratorExp<EClassifier, EParameter> ie) {
// special behavior in LHS mode for outermost expression
if (ie.eContainer() == null) {
assert (ie.getSource().getType() instanceof PredefinedType<?>)
&& (ie.getBody() instanceof PropertyCallExp)
&& OCLStandardLibraryUtil.getOperationCode(ie.getName()) == PredefinedType.COLLECT))
// evaluate source
Object sourceValue = ie.getSource().accept(getVisitor());
// retrieve result list
List<EObject> resultList = new ArrayList<EObject>();
for (Object obj : (Collection<?>) sourceValue)
resultList.add((EObject) obj);
return new Pair<EStructuralFeature, List<EObject>>(
((PropertyCallExp<EClassifier, EStructuralFeature>) ie.getBody())
.getReferredProperty(), resultList);
}
// regular processing
return super.visitIteratorExp(ie);
}
]]>