Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 312604 - [Xpand] ONFILECLOSE works only for the first file
Summary: [Xpand] ONFILECLOSE works only for the first file
Status: CLOSED FIXED
Alias: None
Product: M2T
Classification: Modeling
Component: Xpand (show other bugs)
Version: 1.0.0   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P3 major (vote)
Target Milestone: SR1   Edit
Assignee: Karsten Thoms CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-12 08:52 EDT by Sebastian Zarnekow CLA
Modified: 2010-08-11 09:32 EDT (History)
4 users (show)

See Also:
sven.efftinge: helios+


Attachments
Sample Project as described in comment#1 (12.18 KB, application/binary)
2010-05-14 04:50 EDT, Karsten Thoms CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sebastian Zarnekow CLA 2010-05-12 08:52:28 EDT
1) Create a the examplary EMF-based Xpand Project
2) Modify Template.xpt to this:

«IMPORT metamodel»

«EXTENSION template::GeneratorExtensions»

«DEFINE main FOR Model»
«EXPAND javaClass FOREACH entities()»
«ENDDEFINE»

«DEFINE javaClass FOR Entity»
	«FILE name+".java"»
		public class «name» {
			«EXPAND fieldDef FOREACH properties(this) ONFILECLOSE» 
			«FOREACH features AS f»
				«properties(this).add(f).isEmpty?"":""-»
				public void «f.setter()»(«f.type.name» «f.name») {
					this.«f.name» = «f.name»;
				}
				
				public «f.type.name» «f.getter()»() {
					return «f.name»;
				}
			«ENDFOREACH»
		}
	«ENDFILE»
«ENDDEFINE»

«DEFINE fieldDef FOR Feature»
				private «type.name» «name»;
«ENDDEFINE»

3) Modify the GeneratorExtensions.ext to
import metamodel;

extension metamodel::Extensions reexport;

getter(Feature this) :
	"get"+name.toFirstUpper();
	
setter(Feature this) :
	"set"+name.toFirstUpper();
	
cached List[Feature] properties(Entity this):
	{};

4) Run the workflow and note the compile errors in Address.java
5) Change the definition in the template to

«DEFINE main FOR Model»
«EXPAND javaClass FOREACH entities().reverse()»
«ENDDEFINE»

6) Run the workflow and note the compile errors in Person.java
Comment 1 Karsten Thoms CLA 2010-05-14 04:50:46 EDT
Created attachment 168512 [details]
Sample Project as described in comment#1
Comment 2 Karsten Thoms CLA 2010-05-14 05:18:49 EDT
In ExpandStatement it was remembered that the statement should be evaluated deferred by setting the flag 'deferredToFileClose'. This flag needed to be resetted in any case, since the same ExpandStatement instance will be used by later evaluations.

Fixed in ExpandStatement 1.14
Comment 3 Sven Efftinge CLA 2010-08-09 09:48:01 EDT
Has this been fixed, Karsten?
Comment 4 Darius Jockel CLA 2010-08-11 09:32:18 EDT
Bug is fixed