Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Could not serialize cross reference error - creating a new model with reference to an existing model
Could not serialize cross reference error - creating a new model with reference to an existing model [message #635076] Mon, 25 October 2010 14:19 Go to next message
Ralf Heilek is currently offline Ralf HeilekFriend
Messages: 12
Registered: July 2009
Junior Member
Hey,

i am using two different grammars to define applications and their nls
bundles. Now i want to implement a wizard to create new nls models from
scratch. In the new nls model wizard the user can select a existing
application domain and on performFinish() the new model should be
serialized (see snippet). The grammars are connected by the
GlobalScopeProvider (Classpath).

final NlsFactory factory = NlsFactory.eINSTANCE;

NlsModel model = factory.createNlsModel();
NlsDomain domain = factory.createNlsDomain();
domain.setReference(getApplicationDomain()); // returns
ApplicationDomain EObject from application model
model.setNlsDomain(domain);

Injector injector = new
NlsDSLStandaloneSetup().createInjectorAndDoEMFRegistration() ;
XtextResourceSet rs = injector.getInstance(XtextResourceSet.class);
XtextResource resource = (XtextResource)
rs.getResource(URI.createURI(pFile.getFullPath().toString()) , true);
resource.getContents().set(0, model);
try {
Map<Object, Object> options = new HashMap<Object, Object>();
SaveOptions.defaultOptions().addTo(options);
resource.save(options);
}
catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

On resource.save(options) i got the following exception...

org.eclipse.xtext.parsetree.reconstr.XtextSerializationExcep tion: Could
not serialize cross reference from
NlsModel.nlsDomain->NlsDomain.reference to
ApplicationModel.application->Application'hans'.domains[0]- >ApplicationDomain'crm'
at
org.eclipse.xtext.parsetree.reconstr.impl.AbstractParseTreeC onstructor$AssignmentToken.serializeInternal(AbstractParseTr eeConstructor.java:254)
at
org.eclipse.xtext.parsetree.reconstr.impl.AbstractParseTreeC onstructor$AbstractToken.serialize(AbstractParseTreeConstruc tor.java:155)
at
org.eclipse.xtext.parsetree.reconstr.impl.AbstractParseTreeC onstructor.write(AbstractParseTreeConstructor.java:739)
at
org.eclipse.xtext.parsetree.reconstr.impl.AbstractParseTreeC onstructor.write(AbstractParseTreeConstructor.java:734)
at
org.eclipse.xtext.parsetree.reconstr.impl.AbstractParseTreeC onstructor.write(AbstractParseTreeConstructor.java:734)
at
org.eclipse.xtext.parsetree.reconstr.impl.AbstractParseTreeC onstructor.serializeSubtree(AbstractParseTreeConstructor.jav a:721)
at
org.eclipse.xtext.parsetree.reconstr.Serializer.serialize(Se rializer.java:55)
at
org.eclipse.xtext.parsetree.reconstr.Serializer.serialize(Se rializer.java:61)
at org.eclipse.xtext.resource.XtextResource.doSave(XtextResourc e.java:287)

The application grammar looks like...

Application :
"application" name=ID "{"
(domains+=ApplicationDomain)*
"}";

ApplicationDomain :
"domain" name=ID "abbreviation" abbreviation=ID ("{"
(domains+=ApplicationDomain)+
"}")?;

....and the nls grammar like...

NlsModel :
(nlsDomain=NlsDomain);

NlsDomain:
"nls of domain" reference=[application::ApplicationDomain|FQN] "{"
(nlsPackages+=NlsPack)+
"}";

I see the post "Exception during serialisation" but it did not helped
me, does anyone have any idea what might wrong?

Thanks, Ralf
Re: Could not serialize cross reference error - creating a new model with reference to an existing m [message #636891 is a reply to message #635076] Wed, 03 November 2010 09:08 Go to previous message
Ralf Heilek is currently offline Ralf HeilekFriend
Messages: 12
Registered: July 2009
Junior Member
Hey,

....problem solved using IResourceDescriptions from injector.

IResourceDescriptions resourceDescriptions =
injector.getInstance(IResourceDescriptions.class);
Iterable<IResourceDescription> all =
resourceDescriptions.getAllResourceDescriptions();
for (IResourceDescription d : all) {
for (IEObjectDescription objd :
d.getExportedObjects(ModelPackage.eINSTANCE.getApplicationDo main())) {
objd.getEObjectOrProxy(); // an application domain
}
}

Regards, Ralf
Previous Topic:extend enum syntax for default values ?
Next Topic:inspecting the EMF model of a grammar
Goto Forum:
  


Current Time: Fri Apr 26 03:03:28 GMT 2024

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

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

Back to the top