I worked through the Tutorials at eclipse.org/Xtext/documentation and get into expanding these samples. Working with the Domainmodel.xtext sample I generate a Java-Classfile for each entity as stated in the Tut.
The DSL specifies an arbitry number of features, aka class properties:
Entity:
'entity' name = ID
('extends' superType = [Entity | QualifiedName])?
'{'
(features += Feature)*
'}'
;
In DomainmodelGenerator.xtend then I added code to generate a JAVA-classconstructor. The XTEND-Forloop cycles through all arguements - looks like this:
def compile_Constructors(Entity e) '''
public «e.name.toFirstUpper»
(
«FOR f : e.features»
«f.type.fullyQualifiedName» «f.name.toFirstUpper»,
«ENDFOR»
)
{}
'''
Problem With this the last parameter there is still a comma emitted. How can I get control in XTEND over the loopindex, to make the generator to emit legal JAVA code?