Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 312604

Summary: [Xpand] ONFILECLOSE works only for the first file
Product: [Modeling] M2T Reporter: Sebastian Zarnekow <sebastian.zarnekow>
Component: XpandAssignee: Karsten Thoms <karsten.thoms>
Status: CLOSED FIXED QA Contact:
Severity: major    
Priority: P3 CC: darius.jockel, karsten.thoms, m2t.xpand-inbox, sven.efftinge
Version: 1.0.0Flags: sven.efftinge: helios+
Target Milestone: SR1   
Hardware: PC   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:
Attachments:
Description Flags
Sample Project as described in comment#1 none

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