Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » XText 1.0.2 - EcoreUtil.copy and ^ escaped not working
XText 1.0.2 - EcoreUtil.copy and ^ escaped not working [message #743398] Fri, 21 October 2011 12:37 Go to next message
Jason Pell is currently offline Jason PellFriend
Messages: 55
Registered: February 2011
Member
Hi,

I have an xtext 1.0.2 model and I am using the ^ to escape reserved words. When I load this model into memory and clone it using EcoreUtil.copy or EcoreUtil2.clone or any combination of Copier().copy I lose the ^ escaped words when it gets serialised back to text. If I simply load the model into memory and then serialise to text (without using a clone / copy) then the ^ remains.

Is there an alternative clone I can use? What feature / attribute has been dropped from the EMF model during a clone that I need to maintain.

I am using Eclipse 3.6.2

Thanks for any assistance.

Re: XText 1.0.2 - EcoreUtil.copy and ^ escaped not working [message #743428 is a reply to message #743398] Fri, 21 October 2011 13:15 Go to previous messageGo to next message
Jason Pell is currently offline Jason PellFriend
Messages: 55
Registered: February 2011
Member
Deleted

[Updated on: Fri, 21 October 2011 14:05]

Report message to a moderator

Re: XText 1.0.2 - EcoreUtil.copy and ^ escaped not working [message #743464 is a reply to message #743428] Fri, 21 October 2011 14:04 Go to previous messageGo to next message
Jason Pell is currently offline Jason PellFriend
Messages: 55
Registered: February 2011
Member
In addition I discovered that the cloned model does not have an eResource(), whereas the original does.

Model model = ...
assertNotNull(model.eResource()); // is true

Model model2 = EcoreUtil2.clone(model);
assertNotNull(model2.eResource()); // is false

I will keep investigating, if this is of any significance.
Re: XText 1.0.2 - EcoreUtil.copy and ^ escaped not working [message #743588 is a reply to message #743464] Fri, 21 October 2011 15:43 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

i cannot respoduce this using Xtext 1.0.2, the greeting example and following code

public class Main {
	
	public static void main(String[] args) throws IOException {
		Injector injector = new MyDslStandaloneSetup().createInjectorAndDoEMFRegistration();
		ResourceSet rs = injector.getInstance(ResourceSet.class);
		Resource r1 = rs.getResource(URI.createURI("src/test.mydsl"), true);
		r1.load(null);
		Model m1 = (Model) r1.getContents().get(0);
		Model m2 = EcoreUtil2.clone(m1);
		Resource r2 = rs.createResource(URI.createURI("src/test2.mydsl"));
		r2.getContents().add(m2);
		r2.save(null);
	}

}


and input model

Hello ^Hello!


ps (using the clone method that delegates to the copy method)

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Fri, 21 October 2011 15:44]

Report message to a moderator

Previous Topic:Xbase and dynamic meta-models
Next Topic:Comment serialization
Goto Forum:
  


Current Time: Fri Apr 26 03:41:46 GMT 2024

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

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

Back to the top