Generating multiple files with xtend [message #717873] |
Mon, 22 August 2011 11:38  |
Eclipse User |
|
|
|
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 11:38] by Moderator
|
|
|
|
|
|
|
Re: (no subject) [message #717917 is a reply to message #717912] |
Mon, 22 August 2011 13:20  |
Eclipse User |
|
|
|
This is exactly what I was looking for; The '« »' syntax is unfamiliar, and I was unaware of what was capable within them.
Thanks a million!
|
|
|
Powered by
FUDForum. Page generated in 0.13191 seconds