Skip to main content



      Home
Home » Modeling » EMF » JMerge and Protected Region
JMerge and Protected Region [message #423860] Wed, 08 October 2008 05:47 Go to next message
Eclipse UserFriend
Hi,

I'm wondering if its possible to modify the emf-merge.xml to support code
protected region in the body of a method.

According to this ibm tutorial :

http://www.ibm.com/developerworks/library/os-ecemf3/

in the listing 6 we have successully get a working prototype with such
feature with the tutorial example.

However when I modify and use the original emf-merge.xml

<merge:pull
sourceGet="Method/getBody"
targetMarkup="^gen$"
targetPut="Method/setBody"/>

with

<merge:pull
sourceGet="Method/getBody"
targetMarkup="^gen$"

sourceTransfer=" (\s*//\s*begin-protected-code.*?//\s*end-protected-code\s*)\ n "
targetPut="Method/setBody"/>

My generated code is not longer merged, in other word the sourceTransfer
attribute break the emf-merge.xml.

As we are working extensively with the emf generator based on JET1 we need
to find a suitable solution to get multiple protected code areas in the
method bodies. This will help us to combine our generators based on EMF
JET1.

Any help will be greatly appreciated.

Best Regards.
Re: JMerge and Protected Region [message #423864 is a reply to message #423860] Wed, 08 October 2008 06:33 Go to previous messageGo to next message
Eclipse UserFriend
Xavier,

The code for processing the patterns are structured as a loop in
JMerger.applyPullRules:

for (boolean match = sourceMatcher.find(sourceStart)
&& targetMatcher.find(targetStart);
match;
match = sourceMatcher.find() &&
targetMatcher.find())
{
result.append(stringValue.substring(index,
sourceMatcher.start(1)));
result.append(targetMatcher.group(1));
index = sourceMatcher.end(1);
}

So in theory, you should be able to have multiple regions...

Try it and monitor what happens in the loop with the debugger...


Xavier Maysonnave wrote:
> Hi,
>
> I'm wondering if its possible to modify the emf-merge.xml to support
> code protected region in the body of a method.
>
> According to this ibm tutorial :
>
> http://www.ibm.com/developerworks/library/os-ecemf3/
>
> in the listing 6 we have successully get a working prototype with such
> feature with the tutorial example.
>
> However when I modify and use the original emf-merge.xml
> <merge:pull sourceGet="Method/getBody"
> targetMarkup="^gen$" targetPut="Method/setBody"/>
> with
>
> <merge:pull sourceGet="Method/getBody"
> targetMarkup="^gen$"
> sourceTransfer=" (\s*//\s*begin-protected-code.*?//\s*end-protected-code\s*)\ n "
>
> targetPut="Method/setBody"/>
> My generated code is not longer merged, in other word the
> sourceTransfer attribute break the emf-merge.xml.
>
> As we are working extensively with the emf generator based on JET1 we
> need to find a suitable solution to get multiple protected code areas
> in the method bodies. This will help us to combine our generators
> based on EMF JET1.
>
> Any help will be greatly appreciated.
>
> Best Regards.
>
Re: JMerge and Protected Region [message #423892 is a reply to message #423864] Thu, 09 October 2008 03:35 Go to previous message
Eclipse UserFriend
Thanks Ed to drive me at the right place to monitor the implemented
behaviour.

I understand now how it works. The source and the target should have a one
to one relationship with protected regions. This is easy to see how it
works with 'user-doc'.

I would like a different behaviour, probably a more sophisticated merge.
I'm going to prototype what I'm thinking and come back here to give you my
feedback.

Best Regards.
Previous Topic:Setting "Root Extends Interface" per class?
Next Topic:Why doesn't AbstractEMFOperation rollback on ERROR Status?
Goto Forum:
  


Current Time: Tue Jul 08 06:13:24 EDT 2025

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

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

Back to the top