Refining Mode: Clone Element and add it to same parent [message #1737868] |
Wed, 13 July 2016 11:33  |
Eclipse User |
|
|
|
Hi,
I'm using ATL EMFTVM in refining mode, and I can't figure out how to add a cloned element to the same parent as the source element. Let's say this is the rule:
rule CopyElement {
from s : MM!Element
to
t1 : MM!Element,
t2 : MM!Element (
-- copy all the things
)
}
When I run this I get a copy of the source element, but it is located outside any container on the same level as the root container. I tried to add it to the correct container by using a do block:
do {
s.refImmediateComposite().elements <- s.refImmediateComposite().elements->append(t2);
}
However, this does nothing, only add the copy of the last matched element to the parent container.
What would be the correct way to do this?
Edit* Some more insight on the behavior:
The rule above is matched several times in my case, and only in the last execution the element is added to the parent container.
It is a large container, so I didn't notice at first. All, but the last copied element, are outside the root container...
[Updated on: Fri, 15 July 2016 09:51] by Moderator
|
|
|
|
Re: Refining Mode: Clone Element and add it to same parent [message #1738207 is a reply to message #1738073] |
Mon, 18 July 2016 03:23  |
Eclipse User |
|
|
|
Hi Dennis,
thank you for your reply.
That was, what I was looking for. Just to add something for completeness: If I only want to copy certain elements I also have to add the condition to the root rule.
It now looks like this:
elements <- s.elements -> union(s.elements -> select(e | condition) -> collect(e | thisModule.resolveTemp(e, 't2')))
|
|
|
Powered by
FUDForum. Page generated in 0.07283 seconds