blob: 0ccffe439fdf07904dbc393da9c4a463e9df15df [file] [log] [blame]
[comment encoding = UTF-8 /]
[**
* Module used to generate an Acceleo module.
* @author sbegaudeau
*/]
[module acceleoModule('http://www.eclipse.org/acceleo/ui/acceleowizardmodel/3.1')/]
[**
* This template is the entry point of the generation of an Acceleo module.
* @param anAcceleoModule The Acceleo module.
*/]
[template public genAcceleoModule(anAcceleoModule : AcceleoModule)]
[comment @main /]
[file (anAcceleoModule.name + '.mtl', false, 'UTF-8')]
['['/]comment encoding = UTF-8 /[']'/]
[if (anAcceleoModule.generateDocumentation)]
['['/]**
* The documentation of the module [anAcceleoModule.name/].
*/[']'/]
[/if]
['['/]module [anAcceleoModule.name/]([anAcceleoModule.metamodelURIs->collect(uri : String | '\'' + uri + '\'')->sep(', ')/])[']'/]
[if (anAcceleoModule.moduleElement.kind = ModuleElementKind::Template)]
[anAcceleoModule.genTemplate()/]
[elseif (anAcceleoModule.moduleElement.kind = ModuleElementKind::Query)]
[anAcceleoModule.genQuery()/]
[/if]
[/file]
[/template]
[**
* This template will generate a basic template.
* @param anAcceleoModule The Acceleo module.
*/]
[template protected genTemplate(anAcceleoModule : AcceleoModule)]
[if (anAcceleoModule.generateDocumentation)]
['['/]**
* The documentation of the template [anAcceleoModule.moduleElement.name/].
* @param [anAcceleoModule.moduleElement.parameterType.variableName()/]
*/[']'/]
[/if]
['['/]template public [anAcceleoModule.moduleElement.name/]([anAcceleoModule.moduleElement.parameterType.variableName()/] : [anAcceleoModule.moduleElement.parameterType/])[']'/]
[if (anAcceleoModule.moduleElement.isMain)]['['/]comment @main/[']'/][/if]
[if (anAcceleoModule.moduleElement.generateFile)]
['['/]file ([anAcceleoModule.moduleElement.parameterType.variableName()/].name, false, 'UTF-8')[']'/]
['['/]/file[']'/]
[/if]
['['/]/template[']'/]
[/template]
[**
* This template will generate a basic query.
* @param anAcceleoModule The Acceleo module.
*/]
[template protected genQuery(anAcceleoModule : AcceleoModule)]
[if (anAcceleoModule.generateDocumentation)]
['['/]**
* The documentation of the query [anAcceleoModule.moduleElement.name/].
* @param [anAcceleoModule.moduleElement.parameterType.variableName()/]
*/[']'/]
[/if]
['['/]query public [anAcceleoModule.moduleElement.name/] ([anAcceleoModule.moduleElement.parameterType.variableName()/] : [anAcceleoModule.moduleElement.parameterType/]) : OclAny = self/[']'/]
[/template]
[template private variableName(aVariableName : String) post(trim())]
[if (aVariableName.toLowerFirst().startsWith('a') or aVariableName.toLowerFirst().startsWith('e') or aVariableName.toLowerFirst().startsWith('i') or aVariableName.toLowerFirst().startsWith('o') or aVariableName.toLowerFirst().startsWith('u') or aVariableName.toLowerFirst().startsWith('y'))]
an[aVariableName/]
[else]
a[aVariableName/]
[/if]
[/template]