| [Xtend2] Where is ONFILECLOSE in Xtend2? [message #682833] |
Sun, 12 June 2011 03:40  |
Jos Warmer Messages: 104 Registered: October 2010 |
Senior Member |
|
|
In Xpand the <<EXTEND>> call has a parameter ONFILECLOSE. This is useful for e.g. capturing imports and writing only after you process ed the complete file.
In Xtend2 the <<EXTEND>> co0ntruct has disappeared, you now use an Xtend2 function instead. However, I cannot find the replacement for the ONFILECLOSE feature. Is it really gone in Xtend2, or am I missing something ?
[Updated on: Sun, 12 June 2011 04:12] Report message to a moderator
|
|
|
|
|
|
|
|
| Re: (no subject) [message #683380 is a reply to message #683375] |
Mon, 13 June 2011 12:22   |
Christian Dietrich Messages: 4412 Registered: July 2009 |
Senior Member |
|
|
Hi,
this import manager just gives you an idea how to solve the problem
(1) Create a Stateful Thing (Import Manager) that collects the Import Stuff
(2) do the body calculation, fill the thing, assign body to a var/val
(3) print out the imports
(4) print out the body
from the domain model example
def compile(Entity e) '''
«val importManager = new ImportManager(true)»
«/* first evaluate the body in order to collect the used types for the import section */
val body = body(e, importManager)»
«IF !(e.packageName.isNullOrEmpty)»
package «e.packageName»;
«ENDIF»
«FOR i:importManager.imports»
import «i»;
«ENDFOR»
«body»
'''
In the easiest case this Import Manager is a simple List/Set
~Christian
[Updated on: Mon, 13 June 2011 12:30] Report message to a moderator
|
|
|
|
|
| Re: (no subject) [message #684160 is a reply to message #683807] |
Wed, 15 June 2011 02:32  |
Alexander Nittka Messages: 1073 Registered: July 2009 |
Senior Member |
|
|
Hi,
but can't you do exactly that now as well? You insert a particular key-String into the text and before passing it to the file system access, you replace them...
Alex
|
|
|
Powered by
FUDForum. Page generated in 0.01934 seconds