| Change method signature, leave method body untouched [message #398541] |
Tue, 14 February 2006 09:44  |
Eclipse User |
|
|
|
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   |
Eclipse User |
|
|
|
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> protected void pullTargetMethod(JMethod
targetMethod)<br>
{<br>
String qualifiedTargetMethodName = targetMethod.getQualifiedName();<br>
JMethod sourceMethod = <br>
(JMethod)sourcePatternDictionary.getMethodMap().get(qualifie dTargetMethodName); <br>
<br>
if (sourceMethod == null && <br>
getControlModel().getRedirect() != null && <br>
targetMethod.getName() != null &&<br>
targetMethod.getName().endsWith(getControlModel().getRedirec t())) <br>
{<br>
int index = qualifiedTargetMethodName.indexOf("("); //)<br>
qualifiedTargetMethodName =<br>
qualifiedTargetMethodName.substring(0, index -
getControlModel().getRedirect().length()) + <br>
qualifiedTargetMethodName.substring(index);<br>
sourceMethod = <br>
(JMethod)sourcePatternDictionary.getMethodMap().get(qualifie dTargetMethodName); <br>
}<br>
<br>
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--
|
|
|
|
Powered by
FUDForum. Page generated in 0.05349 seconds