Issue with JMerge [message #42306] |
Wed, 27 February 2008 18:45 |
Eclipse User |
|
|
|
Originally posted by: confmb.capgroup.com
I am trying to use JMerge with jet and I am having some difficulty with
it. Hopefully someone can help me...
For example in a generated class I have the following code entered by the
user:
// BEGIN user region "Other Constructors"
// @generated
public AccountBO(int i) {
// whatever here - should disappear...
}
// END user region "Other Constructors"
// BEGIN user region "Custom Methods"
// @!generated
public static void vvvv() {
//some silly code here...
}
// END user region "Custom Methods"
My understanding is that the code with @generated should be overwritten
during the next generation and the code with @!generated should not.
Unfortunately - none of the code is overwritten. I mean the whole class is
not chnaged.
Sometimes - depending on where I put the jmerge tag - I got all my imports
statement being duplicated everytime I regenerate. This happens with this
template:
package <c:get select="$currentClass/@namespace"/>;
<java:merge/>
<java:importsLocation package="$currentClass/@namespace"/>
This issue does not manifest when I write my template like this:
package <c:get select="$currentClass/@namespace"/>;
<java:importsLocation package="$currentClass/@namespace"/>
<java:merge/>
Anyhow - this is not an issue since chnaging the order fixes the problem.
On the other hand - having JMerge not chnaging my entire class is a big
issue:
How is this possible?
Is JMerge looking for the string "@generated" or "generated"? Becuase I
got the "generated" string in many places in the code. Could this be why
jmerge seems so confused?
But I dont have the string "@generated" anywhere but inside the user
regions. I thought this is what I needed to do by reading the
documentation. Is this correct? Or do I need the "@generated" string at
the class level as well?
Thank you for your help,
BTW: I think jet is a great tool and thank you for making it. It a million
times better than anyhting else outthere. And it is so much more useful
than an MDA tool which forces to use graphics (which is so unproductive).
So congratulation on a great job done for JET.
Frederic
|
|
|
Re: Issue with JMerge [message #42341 is a reply to message #42306] |
Wed, 27 February 2008 18:54 |
Eclipse User |
|
|
|
Originally posted by: merks.ca.ibm.com
This is a multi-part message in MIME format.
--------------020000040301010600060207
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit
Frederic,
Unless you are writing your own merge rules, I'd expect the default ones
to be applied. They pay attention to @generate within /**/ style
comments, but not within // comments. Here's a typical example:
| /**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
*public **int *getPages()
{
*return *pages;
}|
Frederic wrote:
> I am trying to use JMerge with jet and I am having some difficulty
> with it. Hopefully someone can help me...
>
> For example in a generated class I have the following code entered by
> the user:
> // BEGIN user region "Other Constructors"
> // @generated
> public AccountBO(int i) {
> // whatever here - should disappear...
> }
> // END user region "Other Constructors"
>
> // BEGIN user region "Custom Methods"
> // @!generated
> public static void vvvv() {
> //some silly code here...
> }
> // END user region "Custom Methods"
>
> My understanding is that the code with @generated should be
> overwritten during the next generation and the code with @!generated
> should not.
>
> Unfortunately - none of the code is overwritten. I mean the whole
> class is not chnaged.
>
> Sometimes - depending on where I put the jmerge tag - I got all my
> imports statement being duplicated everytime I regenerate. This
> happens with this template:
> package <c:get select="$currentClass/@namespace"/>;
> <java:merge/>
> <java:importsLocation package="$currentClass/@namespace"/>
>
> This issue does not manifest when I write my template like this:
> package <c:get select="$currentClass/@namespace"/>;
> <java:importsLocation package="$currentClass/@namespace"/>
> <java:merge/>
>
> Anyhow - this is not an issue since chnaging the order fixes the problem.
>
> On the other hand - having JMerge not chnaging my entire class is a
> big issue:
> How is this possible?
> Is JMerge looking for the string "@generated" or "generated"? Becuase
> I got the "generated" string in many places in the code. Could this be
> why jmerge seems so confused?
> But I dont have the string "@generated" anywhere but inside the user
> regions. I thought this is what I needed to do by reading the
> documentation. Is this correct? Or do I need the "@generated" string
> at the class level as well?
>
> Thank you for your help,
>
> BTW: I think jet is a great tool and thank you for making it. It a
> million times better than anyhting else outthere. And it is so much
> more useful than an MDA tool which forces to use graphics (which is so
> unproductive).
> So congratulation on a great job done for JET.
>
> Frederic
>
>
--------------020000040301010600060207
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: 8bit
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-15"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Frederic,<br>
<br>
Unless you are writing your own merge rules, I'd expect the default
ones to be applied.
|
|
|
Re: Issue with JMerge [message #42359 is a reply to message #42341] |
Wed, 27 February 2008 21:11 |
Eclipse User |
|
|
|
Originally posted by: confmb.capgroup.com
Thanks a million for your answer.
But I am not sure I really understand it.
Do you mean that for Java code I need to write the templates the following
way?
/**
* This is the default constructor.
* @generated
*/
public <c:get select="$currentClass/@name" />() {
super();
<c:userRegion>
// BEGIN user region <Default Constructor>
<c:initialCode unmodifiedMarker="@generated">
initialCode here...
</c:initialCode>
// END user region <Default Constructor>
</c:userRegion>
}
If - then only code with javadoc can use JMerge - right?
I mean how would you do a user region in a class that can not have javadoc
still comment?
<c:userRegion>
// BEGIN user region <Other Methods>
<c:initialCode unmodifiedMarker="@generated">
initialCode here...
</c:initialCode>
// END user region <Other Methods>
</c:userRegion>
Frederic,
Tx
|
|
|
Re: Issue with JMerge [message #42391 is a reply to message #42359] |
Wed, 27 February 2008 21:22 |
Eclipse User |
|
|
|
Originally posted by: merks.ca.ibm.com
Frederic,
I should probably let Paul answer, since I don't know what rules are in
effect by default for you.
When EMF uses JMerge for its generator, there is a rule that says, if
there methods with matching signatures in the source and the target and
the target is marked @generated, then copy the body of the method from
the source to the target.
<merge:dictionaryPattern
name="generatedUnmodifiableMembers"
select="Member/getComment"
match="@\s*(gen)erated\s*(This
field/method[^(?:\n\r?|\r\n?)]*)*(?:\n\r?|\r\n?)"/>
<merge:pull
sourceGet="Method/getBody"
targetMarkup="^gen$"
targetPut="Method/setBody"/>
Frederic wrote:
> Thanks a million for your answer.
> But I am not sure I really understand it.
>
> Do you mean that for Java code I need to write the templates the
> following way?
>
> /**
> * This is the default constructor.
> * @generated
> */
> public <c:get select="$currentClass/@name" />() {
> super();
> <c:userRegion>
> // BEGIN user region <Default Constructor>
> <c:initialCode unmodifiedMarker="@generated">
> initialCode here...
> </c:initialCode>
> // END user region <Default Constructor>
> </c:userRegion>
> }
>
> If - then only code with javadoc can use JMerge - right?
>
> I mean how would you do a user region in a class that can not have
> javadoc still comment?
>
> <c:userRegion>
> // BEGIN user region <Other Methods>
> <c:initialCode unmodifiedMarker="@generated">
> initialCode here...
> </c:initialCode>
> // END user region <Other Methods>
> </c:userRegion>
>
> Frederic,
>
> Tx
>
|
|
|
|
Re: Issue with JMerge [message #42473 is a reply to message #42442] |
Wed, 27 February 2008 23:27 |
Eclipse User |
|
|
|
Originally posted by: confmb.capgroup.com
This is very interesting Paul, and maybe this explains the problem. I am
going to have to test it.
Paul, are you saying that I can use userRegion alone and not have the
<java:merge> tag at all?
This might be exactly what I need - it seems that the userRegion tag
should be enough for what I need.
PS: Sorry if I missed that fact in the documentation - I thought I read
all of it many times but maybe I missed it - or maybe it is not there.
If you could just confirm that the user region tags alone are sufficinet
and I dont need the <java:merge> tag at all then this would help me make
progress.
Thanks a million,
and great product by the way.
Frederic
|
|
|
Re: Issue with JMerge [message #42499 is a reply to message #42473] |
Thu, 28 February 2008 02:34 |
Eclipse User |
|
|
|
Originally posted by: confmb.capgroup.com
I tried with only the user region tag and the entire class was
regenerated. The user code was overwritten even when the @generated String
was remove.
Does anyone has an example of template that uses the user region tag and
that works. Maybe I am doing something wrong - but I can not find a
solution to this problem.
My template is like this:
<c:userRegion>
// BEGIN user region <Other Method>
<c:initialCode unmodifiedMarker="@generated">
// @generated
</c:initialCode>
// END user region <Other Method>
</c:userRegion>
I must be missing something, what could it be?
Frederic
|
|
|
|
Re: Issue with JMerge [message #42858 is a reply to message #42553] |
Fri, 07 March 2008 21:33 |
Eclipse User |
|
|
|
Originally posted by: confmb.capgroup.com
Paul - sorry for the delayed answer,
Becuase you said it is working for you I have done more testing in order
to be as specific as I can to explain what I see.
Below I include my full template - in order to help us communicate more
specificaly.
A few remark:
- I do have multiple user region. Is this ok?
- The user region inside the constructor never works - the code is
overwritten everytime.
- The third user region almosr never works - code overwritten everytime.
But I think I saw it working before on occasions.
- The second user region works almost always. Except that it works in
reverse - that is if I leave the tag @generated_OtherConstructor alone
then it does not overwritte my code. If I chnage the tag to
@!generated_OtherConstructor - then it overwrite the code. This is the
opposite behavior from what is explained in the documentation. Pretty
wierd isn't it?
- I have the text @generated somewhere in the comments of the class. Does
it matter? Isn't the tool suppose to parse the text of the class and only
worry about what is inside the user region markup comments?
For me these markups are :
// BEGIN user region <OtherMethod>
and // END user region <OtherMethod>
Are they ok? Is there a specific convention I should follow?
- About the unmodifiedMarker. Since I ahve multiple user region in the
class then these markups have different names. Is this ok? If not how
could jet distinguish between regions?
I hope this is more specific and will help find out what is going on.
If you can solve this problem for me then I will certainly be very
grateful.
This issue is preventing us from using jet more within our company. We
need to have some generated code be customized by the users and not
overwritten later.
Thanks a lot in adavance.
Frederic
___________________________Beginning of template_________________________
<c:include template="templates/class/class.codegen.comment.jet"/>
package <c:get select="$currentClass/@namespace"/>;
<java:importsLocation package="$currentClass/@namespace"/>
/**
* Documentation for the class <c:get select="$currentClass/@name"/>:
*
* This class contains the business functionality method associated with
this class.
* The infrastructure functionality for this class is auto generated and
is implemented in the class '{@link <java:import><c:get
select="$currentClass/@namespace"/>._g.<c:get
select="$currentClass/@name"/>_g</java:import>}'.
* <c:if test="$currentClass/@comment">
* <c:get select="$currentClass/@comment"/>
* </c:if>
*
* You can change the code in the user region. To prevent your changes
from being overwritten the next time the code is regenerated - please
remove the @generated tag.
*/
<c:include template="templates/class/jpa/EntityType.annotation.java.jet "/>
<c:include
template="templates/class/jpa/TableMapping.annotation.java.jet "/>
public class <c:get select="$currentClass/@name"/> extends
<java:import><c:get select="$currentClass/@namespace"/>._g.<c:get
select="$currentClass/@name"/>_g</java:import> {
<c:if test="$currentClass/@object-serializable-UID">
<c:include template="templates/field/SerializableUID.java.jet"/>
</c:if>
/**
* This is the default constructor.
*/
public <c:get select="$currentClass/@name" />() {
super();
<c:userRegion>
// BEGIN user region <DefaultConstructor>
<c:initialCode unmodifiedMarker="@generated_DefaultConstructor">
// @generated_DefaultConstructor
// initial code here...
</c:initialCode>
// END user region <DefaultConstructor>
</c:userRegion>
}
<c:userRegion>
// BEGIN user region <OtherConstructor>
<c:initialCode unmodifiedMarker="@generated_OtherConstructor">
// @generated_OtherConstructor
// initial code here...
</c:initialCode>
// END user region <OtherConstructor>
</c:userRegion>
<c:userRegion>
// BEGIN user region <OtherMethod>
<c:initialCode unmodifiedMarker="@generated_OtherMethod">
// @generated_OtherMethod
// initial code here...
</c:initialCode>
// END user region <OtherMethod>
</c:userRegion>
}
___________________________End of template_________________________
|
|
|
Re: Issue with JMerge [message #42889 is a reply to message #42553] |
Fri, 07 March 2008 21:35 |
Eclipse User |
|
|
|
Originally posted by: confmb.capgroup.com
Forgot to mention -
I am not sure which version of jet I am using.
How can I check this out?
I remember taking the latest available a couple month ago.
Frederic
|
|
|
Re: Issue with JMerge [message #42984 is a reply to message #42858] |
Wed, 12 March 2008 02:41 |
Eclipse User |
|
|
|
Originally posted by: confmb.capgroup.com
Does anyone has any idea?
Sorry to bother you about this...
I am just wondeing if I should just not use userRegion.
Should I use JMerge instead? JMerge seems to me very complicated - but of
course maybe it is not.
is it worth a try?
Has anyone been successful with userRegion the way I described it in my
previous post?
You know with multiple of them in one template and also nested inside
methods.
Question 1: If anyone has managed to make it work: could you send me a
template where it is used multiple times? - that way I could maybe find
what is wrong in mine.
Question 2: Has any userRegion issue been fixed recently? Should I get the
latest version of jet?
Frederic
|
|
|
|
Powered by
FUDForum. Page generated in 0.03758 seconds