Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » eContainer becomes null after model transformation(eContainer becomes null after model transformation)
icon5.gif  eContainer becomes null after model transformation [message #1692263] Tue, 14 April 2015 15:53 Go to next message
Arshad Adavani is currently offline Arshad AdavaniFriend
Messages: 163
Registered: July 2013
Location: Bangalore
Senior Member
Hi all,

I have a language something like:

entity MyEntity {
x=5
MyObj[x] {
...
}
}


So when generators are called I transform my model and MyObj[x] will be transformed to 5 copies . Something like MyObj_1, MyObj_2, MyObj_3, MyObj_4 and MyObj_5.

And then I set the new references created and remove the old reference from entity MyEntity I.e. my root object.

But after transformation all the 5 objects loses eContainer information and it becomes null... Any idea and suggestions?


Thanks for any help Smile


Arshad
Re: eContainer becomes null after model transformation [message #1692264 is a reply to message #1692263] Tue, 14 April 2015 15:56 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3109
Registered: July 2009
Senior Member
Please provide more information, e.g how do you trigger your code /
transformation?

Best,
Sebastian
--
Looking for professional support for Xtext, Xtend or Eclipse Modeling?
Find help at http://xtext.itemis.com or xtext(@)itemis.com
Blog: zarnekow.blogspot.com
Twitter: @szarnekow
Google+: https://www.google.com/+SebastianZarnekow
Re: eContainer becomes null after model transformation [message #1692269 is a reply to message #1692263] Tue, 14 April 2015 16:32 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7099
Registered: July 2009
Senior Member
Hi

Seems like a classic case of child-stealing.

See page 6 of
https://www.eclipse.org/mmt/qvt/docs/ICMT2014/QVTtraceability.pdf.

Put

@Override
protected void eBasicSetContainer(InternalEObject newContainer, int
newContainerFeatureID) {
if (newContainer != null) {
EObject oldContainer = eInternalContainer();
assert (oldContainer == null) || oldContainer.eIsProxy() ||
(newContainer == oldContainer) || (oldContainer.eResource() == null);
}
super.eBasicSetContainer(newContainer, newContainerFeatureID);
}

in your root EObjectImpl and it'll show you where it happens.

Regards

Ed Willink


On 14/04/2015 16:53, Arshad Adavani wrote:
> Hi all,
>
> I have a language something like:
>
> entity MyEntity {
> x=5
> MyObj[x] {
> ..
> }
> }
>
> So when generators are called I transform my model and MyObj[x] will
> be transformed to 5 copies . Something like MyObj_1, MyObj_2, MyObj_3,
> MyObj_4 and MyObj_5.
>
> And then I set the new references created and remove the old reference
> from entity MyEntity I.e. my root object.
>
> But after transformation all the 5 objects loses eContainer
> information and it becomes null... Any idea and suggestions?
>
>
> Thanks for any help :)
Re: eContainer becomes null after model transformation [message #1692275 is a reply to message #1692264] Tue, 14 April 2015 16:56 Go to previous messageGo to next message
Arshad Adavani is currently offline Arshad AdavaniFriend
Messages: 163
Registered: July 2013
Location: Bangalore
Senior Member
Hi Sebastian,

Thanks for your reply..

After the save of the file, when dogenerate() method is called, I call a function to transform my model.

Here I do nothing special than using,

var newObj=EcoreUtil.copy(original object)


And then renaming newObj.name to MyObj_1, so on..

And after this i have eContainer set to null...

Not sure what's going wrong..


Regards,
Arshad


Arshad
Re: eContainer becomes null after model transformation [message #1692294 is a reply to message #1692275] Tue, 14 April 2015 21:05 Go to previous message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3109
Registered: July 2009
Senior Member
#doGenerate is not supposed to modify the resource. You may want to
create a copy, manipulate that and save it afterwards. That would
probably work for you. I'm still not sure what you expected from that
transformation or what you wanted to do with the transformation result.
Information like this would help to give better advice.

Best,
Sebastian
--
Looking for professional support for Xtext, Xtend or Eclipse Modeling?
Find help at http://xtext.itemis.com or xtext(@)itemis.com
Blog: zarnekow.blogspot.com
Twitter: @szarnekow
Google+: https://www.google.com/+SebastianZarnekow
Previous Topic:syntactic predicates / references
Next Topic:if/elsif
Goto Forum:
  


Current Time: Tue Apr 20 08:44:11 GMT 2021

Powered by FUDForum. Page generated in 0.01954 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top