Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [acceleo] check for already generated java code
[acceleo] check for already generated java code [message #726888] Mon, 19 September 2011 19:41 Go to next message
Leonardo Kenji Shikida is currently offline Leonardo Kenji ShikidaFriend
Messages: 37
Registered: July 2009
Member
Hi

I would like to know if this is feasible.

I am generating java code from a model.

I can´t check beforehands if the method I am generating already exists in the code.

For example, suppose something like this

[for (aJavaMethod : JavaMethod | aJavaClass.javaMethods)]
[aJavaMethod.gen()/]
[/for]

If my java method is something like

[template public gen (aJavaMethod : JavaMethod) ]
public void [aJavaMethod.name/](){}
[/template]

How could I check if I am not trying to generate an already existent method? (solutions such as adding model validations won´t help me because the real situation I have here is quite complex, this example is only for me to explain the problem)

TIA

Kenji
Re: [acceleo] check for already generated java code [message #727010 is a reply to message #726888] Tue, 20 September 2011 07:54 Go to previous messageGo to next message
Stephane Begaudeau is currently offline Stephane BegaudeauFriend
Messages: 458
Registered: April 2010
Location: Nantes (France)
Senior Member

Hi,

You would have to create a Java service to check "manually" but on the other hand you may be able to handle your problem with JMerge based tags. If you are not familiar with JMerge, you can have a look here.

Regards,

Stephane Begaudeau, Obeo

--
Twitter: @sbegaudeau
Google+: stephane.begaudeau
Blog: http://stephanebegaudeau.tumblr.com
Acceleo Documentation: http://docs.obeonetwork.com/acceleo
Re: [acceleo] check for already generated java code [message #727112 is a reply to message #727010] Tue, 20 September 2011 12:39 Go to previous messageGo to next message
Leonardo Kenji Shikida is currently offline Leonardo Kenji ShikidaFriend
Messages: 37
Registered: July 2009
Member
Hi Stephane

thanks for the suggestions.

but I still have a doubt.

let´s suppose I try something like this

[for (aJavaMethod : JavaMethod | aJavaClass.javaMethods)]
[if (checkForExistentMethod(aJavaMethod))]
[aJavaMethod.gen()/]
[/if]
[/for]

on each iteration of aJavaMethod.gen() (an acceleo template method), the code is changed or all the changes are buffered in memory to be applied only in the end of the [file] directive? If it´s the second option, I guess there´s nothing I can do.

TIA

Kenji
Re: [acceleo] check for already generated java code [message #727417 is a reply to message #727112] Wed, 21 September 2011 09:00 Go to previous message
Stephane Begaudeau is currently offline Stephane BegaudeauFriend
Messages: 458
Registered: April 2010
Location: Nantes (France)
Senior Member

Hi,

The file is generated only at the end of the "file" block but while you are generating your code you can still have a look at the previous version of the generated file.

Regards,

Stephane Begaudeau, Obeo

--
Twitter: @sbegaudeau
Google+: stephane.begaudeau
Blog: http://stephanebegaudeau.tumblr.com
Acceleo Documentation: http://docs.obeonetwork.com/acceleo
Previous Topic:[acceleo 3.1] change metamodel resolving?
Next Topic:[Acceleo] Codebeautifier and conditional codegeneration
Goto Forum:
  


Current Time: Thu Mar 28 13:50:57 GMT 2024

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

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

Back to the top