| [Acceleo] How to get types for xcore meta-model [message #1378574] |
Sat, 24 May 2014 05:36  |
Eclipse User |
|
|
|
Hi
I am using xcore for my meta-model, and am trying to use acceleo to generate classes.
Below is my acceleo template.
Here is a snippet from my xcore model:
class Role{
String name
}
My current acceleo template- which is obviously incorrect - is generating:
public class Role{
private org.eclipse.emf.ecore.xcore.XAttribute name;
public Name getName getName() {
return this.name;
}
How can I do find the type - in this case String - in the acceleo template?
[comment encoding = UTF-8 /]
[**
* The documentation of the module generate.
*/]
[module generate('http://www.eclipse.org/emf/2011/Xcore')]
[**
* The documentation of the template generateElement.
* @param aXClass
*/]
[template public generateElement(aXClass : XClass)]
[comment @main/]
[file (aXClass.name.concat('.java'), false, 'UTF-8')]
public class [aXClass.name.toUpperFirst()/]{
[for (m: XMember | aXClass.members) separator('\n')]
private [m.type.eContainer().eClass().instanceTypeName /] [m.name.toLowerCase()/];
[/for]
[for (p: XMember | aXClass.members) separator('\n')]
public [p.name.toString().toUpperFirst() /] get[p.name.toUpperFirst()/] get[p.name.toUpperFirst()/]() {
return this.[p.name/];
}
[/for]
[for (o: XOperation | aXClass.) separator('\n')]
public [o.type.name/] [o.name/]() {
// TODO should be implemented
}
[/for][/comment]
[comment]
[for (p: Property | aClass.attribute) separator('\n')]
public [p.type.name/] get[p.name.toUpperFirst()/]() {
return this.[p.name/];
}
[/for]
[for (o: Operation | aClass.ownedOperation) separator('\n')]
public [o.type.name/] [o.name/]() {
// TODO should be implemented
}
[/for][/comment]
}
[/file]
[/template]
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.11518 seconds