Skip to main content



      Home
Home » Modeling » EMF » Change method signature, leave method body untouched
Change method signature, leave method body untouched [message #398541] Tue, 14 February 2006 09:44 Go to next message
Eclipse UserFriend
Hi,

I have created a JET-Template that generates Java-Code. The methods
signature, as well as the return value, is based on my defined
EMF-Model. The method names are unique.
So, if I change something in my emf-model the signatures of my methods
would also be changed. But If I write something in the body, it gets
deleted.

Now the question:
Is it possible to change the methods signature and leave the method body
untouched.

I know, normally the signature of the method is unique and not the
methods name...

Any idea?

Thanks,
Sandro
Re: Change method signature, leave method body untouched [message #398542 is a reply to message #398541] Tue, 14 February 2006 10:04 Go to previous messageGo to next message
Eclipse UserFriend
This is a multi-part message in MIME format.
--------------090704060707070207000608
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Sandro,

If you are using JMerger, the matching is done by signature, so you'd
have to override this method to do that differently:

protected void pullTargetMethod(JMethod targetMethod)
{
String qualifiedTargetMethodName = targetMethod.getQualifiedName();
JMethod sourceMethod =

(JMethod)sourcePatternDictionary.getMethodMap().get(qualifie dTargetMethodName);

if (sourceMethod == null &&
getControlModel().getRedirect() != null &&
targetMethod.getName() != null &&

targetMethod.getName().endsWith(getControlModel().getRedirec t()))
{
int index = qualifiedTargetMethodName.indexOf("("); //)
qualifiedTargetMethodName =
qualifiedTargetMethodName.substring(0, index -
getControlModel().getRedirect().length()) +
qualifiedTargetMethodName.substring(index);
sourceMethod =

(JMethod)sourcePatternDictionary.getMethodMap().get(qualifie dTargetMethodName);
}

map(sourceMethod, targetMethod);

Even if your template doesn't produce results with overloaded
signatures, the client could still add them and cause grief.


Sandro wrote:
> Hi,
>
> I have created a JET-Template that generates Java-Code. The methods
> signature, as well as the return value, is based on my defined
> EMF-Model. The method names are unique.
> So, if I change something in my emf-model the signatures of my methods
> would also be changed. But If I write something in the body, it gets
> deleted.
>
> Now the question:
> Is it possible to change the methods signature and leave the method
> body untouched.
>
> I know, normally the signature of the method is unique and not the
> methods name...
>
> Any idea?
>
> Thanks,
> Sandro


--------------090704060707070207000608
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Sandro,<br>
<br>
If you are using JMerger, the matching is done by signature, so you'd
have to override this method to do that differently:<br>
<blockquote><small>&nbsp; protected void pullTargetMethod(JMethod
targetMethod)<br>
&nbsp; {<br>
&nbsp;&nbsp;&nbsp; String qualifiedTargetMethodName = targetMethod.getQualifiedName();<br>
&nbsp;&nbsp;&nbsp; JMethod sourceMethod = <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
(JMethod)sourcePatternDictionary.getMethodMap().get(qualifie dTargetMethodName); <br>
<br>
&nbsp;&nbsp;&nbsp; if (sourceMethod == null &amp;&amp; <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; getControlModel().getRedirect() != null &amp;&amp; <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; targetMethod.getName() != null &amp;&amp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
targetMethod.getName().endsWith(getControlModel().getRedirec t())) <br>
&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int index = qualifiedTargetMethodName.indexOf("("); //)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; qualifiedTargetMethodName =<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; qualifiedTargetMethodName.substring(0, index -
getControlModel().getRedirect().length()) + <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; qualifiedTargetMethodName.substring(index);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sourceMethod = <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;
(JMethod)sourcePatternDictionary.getMethodMap().get(qualifie dTargetMethodName); <br>
&nbsp;&nbsp;&nbsp; }<br>
<br>
&nbsp;&nbsp;&nbsp; map(sourceMethod, targetMethod);</small><br>
</blockquote>
Even if your template doesn't produce results with overloaded
signatures, the client could still add them and cause grief.<br>
<br>
<br>
Sandro wrote:
<blockquote cite="middssqce$8d9$1@utils.eclipse.org" type="cite">Hi,
<br>
<br>
I have created a JET-Template that generates Java-Code. The methods
signature, as well as the return value, is based on my defined
EMF-Model. The method names are unique.
<br>
So, if I change something in my emf-model the signatures of my methods
would also be changed. But If I write something in the body, it gets
deleted.
<br>
<br>
Now the question:
<br>
Is it possible to change the methods signature and leave the method
body untouched.
<br>
<br>
I know, normally the signature of the method is unique and not the
methods name...
<br>
<br>
Any idea?
<br>
<br>
Thanks,
<br>
Sandro
<br>
</blockquote>
<br>
</body>
</html>

--------------090704060707070207000608--
Re: Change method signature, leave method body untouched [message #398546 is a reply to message #398542] Tue, 14 February 2006 15:00 Go to previous message
Eclipse UserFriend
Hi Ed,

thank you for your fast reply. With your suggestion you saved my day ;-)

Sandro
Previous Topic:DeleteCommand, children
Next Topic:Simple Modification of generated EMF editor
Goto Forum:
  


Current Time: Wed Nov 05 13:55:11 EST 2025

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

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

Back to the top