Community
Participate
Working Groups
We should either make sure that this is implemented or not expose it in the code assist and validation. Right now : aql:self->asSequence()->intersection(self->asSequence()) returns nothing. in MTL self->asSequence()->intersection() does not exit on the other hand : self->asBag()->intersection(Bag other) exists. "Bag" is "a non ordered List", as such might contains dupplicates. We should implement intersection(List/List) in MTL with the same behavior as MTL's intersection on Bags in order to ease the migration path.
It looks like the MTL version is implemented here: org.eclipse.ocl.util.CollectionUtil.intersection(Collection<? extends E>, Collection<? extends E>) in particular : // loop over the smaller collection and add only elements // that are in the larger collection if (self.size() > c.size()) { for (E e : c) { if (includes(self, e)) { result.add(e); } } } else { for (E e : self) { if (includes(c, e)) { result.add(e); } } } which is "ok" from a specification point of view but is not conform to what we want to achieve : the order of the result might vary depending on whether the first list has more elements than the second. *We want an order which, even if it's not defined explicitely, is predictable and constant whatever the input model is*. The principle of least surprise. Implementing it with a List.retainAll() calls seems like the way to go, order is kept, dupplicates in the first operand are kept but removed if are in the second operand.
Review https://git.eclipse.org/r/47599 submitted to introduce "intersection" on Lists, and allow intersections between lists and sets (or the reverse).
merged and fixed for RC1
The validation of the intersection service should be implemented. Some ideas: - remove types with no common ancestor between the two collections - add both types if common ancestor
for validation add the lowest common ancestor instead of both types
New Gerrit change created: https://git.eclipse.org/r/48880
Gerrit change https://git.eclipse.org/r/48880 was merged to [master]. Commit: http://git.eclipse.org/c/acceleo/org.eclipse.acceleo.git/commit/?id=d13c24bb0a9b6b2239147bfb9d7e7cc8b014d390
Tests has been added and a little fix has been made on the validation.