Generating multiple files with xtend [message #717873] |
Mon, 22 August 2011 15:38 |
darkdigitaldream Messages: 7 Registered: August 2011 |
Junior Member |
|
|
I've been learning about code generation with xtend, and I've run out of documentation to help me along.
I'm attempting to generate multiple files with xtend, specifically one file for each of a list of model elements. To use the fowlerdsl example as a reference, a java function is generated for each command in the state machine via the call to declareCommand(Command):
«FOR c : sm.commands»
«c.declareCommand»
«ENDFOR»
//...more code generation...
def declareCommand(Command command){
}
When the fowlerDSL example generates the StateMachine, it uses a resource labelled "IFileSystemAccess fsa" who's entry point into the .xtext file is at the declaration of the doGenerate() function
My question, then, is how do I bring the IFileSystemAccess class from the doGenerate function into the declareCommand function, allowing me to generate a .java file for each command in the DSL? I've tried the following, with no luck:
«FOR c : sm.commands»
«c.declareCommand, fsa»
«ENDFOR»
//...more code generation...
def declareCommand(Command command, IFileSystemAccess fsa){
//I hope to call fsa.generateFile() here
}
Edit: code block formatting
[Updated on: Mon, 22 August 2011 15:38] Report message to a moderator
|
|
|
|
|
|
(no subject) [message #717912 is a reply to message #717889] |
Mon, 22 August 2011 16:43 |
|
hi,
why not passing fsa as you would do it in java???
«FOR c : sm.commands»
«c.declareCommand(fsa)»
«ENDFOR»
def declareCommand(Command command, IFileSystemAccess fsa){
fsa.generateFile("com"+command.Name+".java",myCommandGenFunction(command))
}
~Christian
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
|
Powered by
FUDForum. Page generated in 0.04035 seconds