Determine differences between two representations of an EObject [message #1231280] |
Tue, 14 January 2014 04:00  |
Eclipse User |
|
|
|
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 02:15  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.33310 seconds