Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » CrossRef Serialization of updated models
CrossRef Serialization of updated models [message #1450333] Wed, 22 October 2014 10:37 Go to next message
Cedric Brun is currently offline Cedric BrunFriend
Messages: 431
Registered: July 2009
Senior Member
First a bit of background. I'm using Sirius with Xtext resources having cross references. When doing some editing in Sirius the ResourceSet is kept consistent, all the Xtext resources are resolved and loaded.

Now when I rename an element which had a cross-ref going to it and the resource is getting saved, the "old" name is still used, effectively breaking the model.

I understand this is because this name is retrieved from the index and not from the model itself, but in my case I think I would need to :
- either change that behavior and have a way to tell to the XtextResource : don't even bother asking the index and use the model instance itself. If possible in a DSL agnostic way ( meaning I can configure Xtext do to that for all the XtextResources by default.)
- update the index or "shadow" it based on my in memory state
- some other solution I could not figure out yet.

I've browsed through a lot of code and examples which *seems* to be related, or could be useful :

ResourceSetBasedResourceDescriptions, ResourceDescriptionsProvider.LIVE_SCOPE but it doesn't look like its getting called during the serialization

What would be the best course of action ?


http://cedric.brun.io news and articles on eclipse and eclipse modeling.
Re: CrossRef Serialization of updated models [message #1450402 is a reply to message #1450333] Wed, 22 October 2014 12:09 Go to previous messageGo to next message
Cedric Brun is currently offline Cedric BrunFriend
Messages: 431
Registered: July 2009
Senior Member
Setting ResourceDescriptionsProvider.LIVE_SCOPE in the resourceset load options seems to do the trick. Would you think it is better to do that or find some way to "inform" the default DirtyAware provider that the resource is dirty ? (or any other solution ? )

http://cedric.brun.io news and articles on eclipse and eclipse modeling.
Re: CrossRef Serialization of updated models [message #1450437 is a reply to message #1450402] Wed, 22 October 2014 12:53 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Cedric,

the cleanest way would be combination of both. All resources that are
currently dirty should participate in the dirty state management of
Xtext. That allows to resolve links against newly created object.
The other part of the live resource descriptions which should be used if
you serialize/ save resources (Resource#save) if their references et al
have been modified.
Generally speaking, your good to go with your current solution.

Best,
Sebastian
--
Looking for professional support for Xtext, Xtend or Eclipse Modeling?
Go visit: http://xtext.itemis.com
Re: CrossRef Serialization of updated models [message #1450512 is a reply to message #1450437] Wed, 22 October 2014 14:20 Go to previous messageGo to next message
Cedric Brun is currently offline Cedric BrunFriend
Messages: 431
Registered: July 2009
Senior Member
Thanks for your answer !
For further references, how should I "notify" Xtext that a resource became dirty ? Right now the isModified flag is set but it doesn't look like Xtext care about that.


http://cedric.brun.io news and articles on eclipse and eclipse modeling.
Re: CrossRef Serialization of updated models [message #1450547 is a reply to message #1450512] Wed, 22 October 2014 14:58 Go to previous message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Am 22.10.14 16:20, schrieb Cedric Brun:
> Thanks for your answer !
> For further references, how should I "notify" Xtext that a resource
> became dirty ? Right now the isModified flag is set but it doesn't look
> like Xtext care about that.

If its in the same resourceSet, there is no need to do that explicitely,
the LIVE_* config will do. If you use different resource sets for
different editors, IDirtyStateManager.manageDirtyState(IDirtyResource)
needs to be used.

Best,
Sebastian
--
Looking for professional support for Xtext, Xtend or Eclipse Modeling?
Go visit: http://xtext.itemis.com
Previous Topic:Add custom field while inferring
Next Topic:Namespace imports in standalone Java application
Goto Forum:
  


Current Time: Fri Mar 29 09:45:57 GMT 2024

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

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

Back to the top