Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Serialization in xtext(Serialization problems in xtext)
icon5.gif  Serialization in xtext [message #1257529] Wed, 26 February 2014 14:32 Go to next message
Arshad Adavani is currently offline Arshad AdavaniFriend
Messages: 163
Registered: July 2013
Location: Bangalore
Senior Member
Hi all,
My grammar snippet is something like:

Model:
	"name" name=QualifiedName
	(entities+=Entity | values+=ValueObj)* 
;


The general behaviour required for me is Entity and ValueObj can exist independent of each other and in any order.

But I have one special case where Entity should be created first before ValueObj is created. Because ValueObj refers to Entity in some cases.

While filling my model I am filling Entity first and then ValueObj. But still I get NoEObjectDescription found exception during serialization, which says a particular entity is not present that a ValueObj is referring to.

How can I avoid this?
I want Entity to be serialized first and then ValueObj.


Thanks in advance Smile


Arshad
Re: Serialization in xtext [message #1257562 is a reply to message #1257529] Wed, 26 February 2014 15:20 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

can you please share a unit test or something like that that reproduces the problem
+ all relevant parts of grammar and scoping etc


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Serialization in xtext [message #1257700 is a reply to message #1257562] Wed, 26 February 2014 18:01 Go to previous messageGo to next message
Arshad Adavani is currently offline Arshad AdavaniFriend
Messages: 163
Registered: July 2013
Location: Bangalore
Senior Member
Hi Christian,
As root node for my grammar is Model, so my code snippets looks like:

Model model=ModelFactor.eINSTANCE.createModel();
model.getEntities().add(HERE I AM ADDING THE ENTITY);
// This entity is searched for while creating ValueObj and reference has been added here.
//....

// Then adding this ValueObj to model.

model.getValueObj().add(VALUEOBJ HERE);

return model;


So model is returned from this method.
And I am creating a resource and saving this content in the calling function.

// creation of a resource here, Say "resource"
resource.getContents().add(model);
try{
resource.save(Collections.EMPTY_MAP);
}
catch (...){
}


It throws me NoEobjectdescription found exception as explained above. ValueObj is getting serialized first. May be problem at the line resource.getContents().add(model);


How can I avoid this?

Thanks in advance Smile


Arshad
Re: Serialization in xtext [message #1257748 is a reply to message #1257700] Wed, 26 February 2014 19:04 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi this should work perfectly but without a reproduce able example it is hard to give any further advice

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Serialization in xtext [message #1266506 is a reply to message #1257700] Fri, 07 March 2014 14:55 Go to previous message
Yann Thierry-Mieg is currently offline Yann Thierry-MiegFriend
Messages: 3
Registered: March 2014
Junior Member
If it helps, the Serialization raising exceptions issue in most cases is due to a ScopeProvider problem (in my limited experience).

Make sure if you designed a custom ScopeProvider that it is registered with bindIScopeProvider (and configureSerializerScopeProvider) in your runtime module.

You can also break under debugger just before the
resource.save(Collections.EMPTY_MAP);
and inspect your model manually under debugger to check the AST node that the exception points to as being in error. The error trace is very long, but right at the top you chould get a pretty precise diagnosis of where to look.

The debugger allows to track issues such as crossrefs pointing to objects in other Resources, or attributes being null due to a forgotten EcoreUtil.copy somewhere etc... as these errors are frequent when building a model programmatically.

gl&hf

yann
Previous Topic:EObjectDescription could be found in Scope during serialization in an osgi environnement
Next Topic:xtext and xtend for generating procedural code
Goto Forum:
  


Current Time: Wed Apr 24 16:08:48 GMT 2024

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

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

Back to the top