Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Cloning/Copying Xtext Resource including node model
Cloning/Copying Xtext Resource including node model [message #1795612] Wed, 26 September 2018 08:28 Go to next message
Panisha RN is currently offline Panisha RNFriend
Messages: 43
Registered: May 2013
Member
I am looking for a way to clone the xtext Resource(deep copy).

I could copy the semantics using the EcoreUtil as shown below

void cloneResource (Resource original, Resource clone)
{
Collection<EObject> clonedContents = EcoreUtil.copyAll(original.getContents());
clone.getContents().addAll(clonedContents);
}

I would like to to do something similar for for the NodeModel as well.

Is there any way to do so?. Please help me.


I had a look into EcoreUtil2 as well and did not found anything which could help.

Thanks in advance.

Regards
Panisha
Re: Cloning/Copying Xtext Resource including node model [message #1795613 is a reply to message #1795612] Wed, 26 September 2018 08:37 Go to previous messageGo to next message
Karsten Thoms is currently offline Karsten ThomsFriend
Messages: 762
Registered: July 2009
Location: Dortmund, Germany
Senior Member

Why not just copy and reparse the file?
Re: Cloning/Copying Xtext Resource including node model [message #1795616 is a reply to message #1795613] Wed, 26 September 2018 08:52 Go to previous messageGo to next message
Panisha RN is currently offline Panisha RNFriend
Messages: 43
Registered: May 2013
Member
Hello Thomas,

Thanks for the reply.

I do not wanted to re-parse the same file.

Is it the only way to clone/copy xtext Resource?

Regards
Panisha
Re: Cloning/Copying Xtext Resource including node model [message #1795634 is a reply to message #1795616] Wed, 26 September 2018 10:23 Go to previous messageGo to next message
Karsten Thoms is currently offline Karsten ThomsFriend
Messages: 762
Registered: July 2009
Location: Dortmund, Germany
Senior Member

The simplest one, since you don't have to care about the NodeModel. It would be created by the parser. I'm not aware of a way to copy it and never needed to do so.
Re: Cloning/Copying Xtext Resource including node model [message #1795641 is a reply to message #1795634] Wed, 26 September 2018 11:18 Go to previous message
Panisha RN is currently offline Panisha RNFriend
Messages: 43
Registered: May 2013
Member
Hello Tomas,

Thanks for the hint.

Re-parsing the resource again worked for me.. I even tried to copy node model manually..had some difficulty.

May be in the long run, API to copy the node mode only is useful to copy something which is not part of the semantic model from one resource to another.

Regards
Panisha
Previous Topic:How to implement scoping and validation for an element at same time
Next Topic:How to control Indexing for Xtext Projects
Goto Forum:
  


Current Time: Thu Mar 28 11:24:41 GMT 2024

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

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

Back to the top