Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community Forums[Acceleo] creating something similar to a JET custom tag with acceleo
https://www.eclipse.org/forums/index.php/mv/msg/210785/677399/#msg_677399
I relay here a question from one of my team members.
Here is the context. We are planning to switch from Jet templates to acceleo. The developer wants to reproduce some features he was using with Jet. In particular, he had a custom tag that was automatically resolving and adding the imports for java classes (don't ask me the difference with the standard jet import tag). How should he implement that function with Acceleo?
Here is the original question:
---------
> When generate a *.java file, It is difficult to computes all the imports to add in
> this .java file at begin.
>
> is there a way that automatically computes the imports to add according to the
> classes you use?
>
>
> for example :
>
> In JET, the user can make a custom tag, it like a pool, the user can add the
> imports string dynamically, then it flush its buffer to a file.
----------
thanks & regards,
Maxime]]>Maxime Jeanmart2011-06-08T11:57:24-00:00Re: [Acceleo] creating something similar to a JET custom tag with acceleo
https://www.eclipse.org/forums/index.php/mv/msg/210785/677445/#msg_677445
With Acceleo, you can call Java code to do pretty much the same in order to keep a list of the import that are to be added to the Java file at the end of the generation. This is something we're planning to add "by default" (much like the "standard jet import tag"), but have not yet.
Laurent Goubet
Obeo]]>Laurent Goubet2011-06-08T14:46:11-00:00Re: [Acceleo] creating something similar to a JET custom tag with acceleo
https://www.eclipse.org/forums/index.php/mv/msg/210785/677447/#msg_677447
In order to do this, you can compute the imports directly in Acceleo. You can see one example of this in this open source UML to Java generator for Acceleo 3 here. You can also use a Java service and compute the type used in the current class in Java and then return a list of those type to print the import in Acceleo.