Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc) » EMF + Texo + Xpand2(Access ecore model annotations in custom texo template)
| | |
Re: EMF + Texo + Xpand2 [message #973188 is a reply to message #973183] |
Tue, 06 November 2012 06:08 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi Pradeep,
How are these annotations stored, in eannotations?
btw, I saw the code you generated in the snippet image, in the templates I always use fully qualified names, texo will
take care of import resolving.
gr. Martin
On 11/06/2012 07:04 AM, Pradeep Badiger wrote:
> Hi Martin,
>
> Thanks for your reply. I was able to add my own template and generate the code. But i need to access custom annotations in my template file.
>
>
>
> How can i achieve this?
>
> thanks,
> Pradeep B
>
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
|
|
| |
Re: EMF + Texo + Xpand2 [message #974652 is a reply to message #974538] |
Wed, 07 November 2012 08:11 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi Pradeep,
You can extend/override the texo templates using XPand. The git location shows several examples of xpand templates:
http://git.eclipse.org/c/texo/org.eclipse.emf.texo.git/tree/generator/org.eclipse.emf.texo.modelgenerator/src/org/eclipse/emf/texo/modelgenerator/templates/
For examples the addition.xpt (see below). Within the define you have access to the ModelGenAnnotation instance (for
EClass, EPackage etc). From the ModelGenAnnotation instance you can find the underlying modelelement as a property, for
example eClass, ePackage etc.
«REM»Template file which can be overridden to generate additional files or code«ENDREM»
«IMPORT org::eclipse::emf::texo::modelgenerator::modelannotations»
«IMPORT org::eclipse::emf::texo::generator»
«REM»Called for EPackages, even if you don't want to generate code for EPackages, still keep this empty DEFINE«ENDREM»
«DEFINE root(ModelController modelController) FOR EPackageModelGenAnnotation-»
«ENDDEFINE»
«REM»Called for EClasses, even if you don't want to generate code for EClasses, still keep this empty DEFINE«ENDREM»
«DEFINE root(ModelController modelController) FOR EClassModelGenAnnotation-»
«ENDDEFINE»
«REM»Called for EEnums, even if you don't want to generate code for EEnums, still keep this empty DEFINE«ENDREM»
«DEFINE root(ModelController modelController) FOR EEnumModelGenAnnotation-»
«ENDDEFINE»
gr. Martin
On 11/07/2012 07:08 AM, Pradeep Badiger wrote:
> Hi Martin,
>
> Yes the metadata required are added as EAnnotations in the model. I need to use this metadata as conditional fields in
> the overridden template to generate additional code in the generated code.
> I was using JET templates earlier which had access to metadata defined on the models which allowed me to control the
> code generation. I was hoping the same when using the Xpand language and Texo.
>
> thanks,
> Pradeep V.B.
>
>
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
|
|
| | |
Re: EMF + Texo + Xpand2 [message #991871 is a reply to message #991053] |
Thu, 20 December 2012 11:37 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi Pradeep,
Sorry missed your post. The file is generated using this directive:
«FILE classFileName(this) java-»
(as an example), so you can determine the filename yourselve.
In the above example the filename is created using this utility:
String classFileName( EClassifierModelGenAnnotation this ): qualifiedClassName.replaceAll("\\.","/") + ".java";
Let me know if you have additional questions.
gr. Martin
On 12/17/2012 09:39 AM, Pradeep Badiger wrote:
> Hi Martin, I am trying to override addtions.xpt and generate a file for every EClass in emf file. I need a different
> package and class name for the new file. How do i override that. I am not able to generate it in a different package. A
> new file is getting generated in with the same name as that of EClass.
>
> Thanks,
> Pradeep V.B.
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
|
|
|
Goto Forum:
Current Time: Fri Apr 26 08:43:16 GMT 2024
Powered by FUDForum. Page generated in 0.03391 seconds
|