Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Determine differences between two representations of an EObject
Determine differences between two representations of an EObject [message #1231280] Tue, 14 January 2014 09:00 Go to next message
Jens Rabe is currently offline Jens RabeFriend
Messages: 81
Registered: September 2013
Member
Let's say I have two EObjects from one file in different states, e.g., when loading an object O and O1 in two contexts, changing the O and saving it back. Then O1 still contains the old O. I now want to update the O1 without unloading it. EMF compare does not always work well because cross references might have changed which results in changed proxy URIs. Applying them to the old parse tree of the resource of O1 leads to unexpected results.

The XtextResource has an update() method where you have to supply the start position, the size of the original text which got changed and the replacement. Is there a way of determining this?

My first step would be to use O.eResource().save() and O1.eResource().save() to save the both resources to Strings using intermediate ByteArrayOutputStreams. Now I need a means to get a list of ReplaceRegions like
List<ReplaceRegion> myRegions = getReplaceRegions(textOfO, textOfO1)

How could I achieve that?
Re: Determine differences between two representations of an EObject [message #1231670 is a reply to message #1231280] Wed, 15 January 2014 07:15 Go to previous message
Sven Efftinge is currently offline Sven EfftingeFriend
Messages: 1823
Registered: July 2009
Senior Member
Why don't you just reparse everything?

Am 14/01/14 10:00, schrieb Jens Rabe:
> Let's say I have two EObjects from one file in different states, e.g.,
> when loading an object O and O1 in two contexts, changing the O and
> saving it back. Then O1 still contains the old O. I now want to update
> the O1 without unloading it. EMF compare does not always work well
> because cross references might have changed which results in changed
> proxy URIs. Applying them to the old parse tree of the resource of O1
> leads to unexpected results.
>
> The XtextResource has an update() method where you have to supply the
> start position, the size of the original text which got changed and the
> replacement. Is there a way of determining this?
>
> My first step would be to use O.eResource().save() and
> O1.eResource().save() to save the both resources to Strings using
> intermediate ByteArrayOutputStreams. Now I need a means to get a list of
> ReplaceRegions like
> List<ReplaceRegion> myRegions = getReplaceRegions(textOfO, textOfO1)
>
> How could I achieve that?


--
Need professional support for Xtext or other Eclipse Modeling technologies?
Go to: http://xtext.itemis.com
Twitter : @svenefftinge
Blog : http://blog.efftinge.de
Previous Topic:Xtext grammar translation bug?
Next Topic:Access a referenced JvmGenericType in the JvmModelInferrer
Goto Forum:
  


Current Time: Sat Jul 11 06:05:57 GMT 2020

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

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

Back to the top