Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » Strange behaviour of EXPAND statement (expand, null-expression)
Strange behaviour of EXPAND statement [message #531515] Wed, 05 May 2010 10:03 Go to next message
Daniel Stieger is currently offline Daniel StiegerFriend
Messages: 24
Registered: April 2010
Junior Member
Hi,

somehow i have a realy strange xpand2 behaviour in an EXPAND call. I have the following code:

«DEFINE statesyntax FOR WFState»
        if state == '«stateName()»': «this.ifstatement.toString()»
«IF ifstatement != null» «EXPAND newstatesyntax FOR ifstatement» «ENDIF»

«ENDDEFINE»


If i ommit the if statement, the expand is executed although ifstatement is null.. I thought that expand wouldn t expand if the FOR expression is null. Isn´t that correct?

Daniel

[Updated on: Wed, 05 May 2010 12:31]

Report message to a moderator

Re: Strange behaviour of EXPAND statement [message #531665 is a reply to message #531515] Wed, 05 May 2010 17:54 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hello Daniel,

yes it should be only invoked when the property is not null. can you share a sample for me that reproduces the problem?

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Strange behaviour of EXPAND statement [message #531777 is a reply to message #531665] Thu, 06 May 2010 07:41 Go to previous messageGo to next message
Daniel Stieger is currently offline Daniel StiegerFriend
Messages: 24
Registered: April 2010
Junior Member
Yes sure,

i m using the following xtext-grammer:

WFState:
	'state' name=ID '{'
	(doc=STRING)?
	('entryaction' ':' pyentryaction=STRING)?
	('exitaction'  ':' pyexitaction=STRING)?
	'}'
	(ifstatement = WFIfStatement (elseifstatments += WFElseIfStatement)*)?
	(gotostatement = WFGotoStatement)?
	(stopstatement = WFFlowstopStatement)?; 

WFGotoStatement:
	'goto' state=[WFState];

WFFlowstopStatement:
	flowstop?='flowstop';

WFIfStatement:
	// 'if' expressions=EXpression 'goto' state=[WFState];
	'if' clause=WFIfClause 'goto' state=[WFState];
	
WFElseIfStatement: 
	'elseif' clause=WFIfClause 'goto'state=[WFState];
	
WFIfClause:
	WFIfClauseEvent | WFIfClauseExpression ;

WFIfClauseEvent:
	'ev' '(' eventname=ID ')'; 

WFIfClauseExpression:
	'(' pyexpression=STRING ')';



and the following model code:
state Entwurf { entryaction: "self.status = 'new'" }
if ("self.lines.count() > 0") goto Angebot
elseif ev(cancel) goto Abbruch

state Angebot { entryaction: "self.status = 'draft'" }
if ev(confirm) goto Beauftragt
elseif ev(cancel) goto Abbruch

state Beauftragt { entryaction: "self.status = 'accepted'" } flowstop
state Abbruch { entryaction: "self.status = 'canceled'" } flowstop 



Then i use the xpand2 template:

REM» WORKFLOW STUFF -------------------------------------------------------------- «ENDREM»

«DEFINE statemachinesyntax FOR WFMainSection»
   ...
«EXPAND statesyntax FOREACH states»
...

«ENDDEFINE»

«DEFINE statesyntax FOR WFState»

ifstatement is: «this.ifstatement.toString()» 
«EXPAND newstatesyntax FOR ifstatement» 
«ENDDEFINE»

«DEFINE newstatesyntax FOR WFIfStatement»
I WAS EXPANDED
«ENDDEFINE»


what generates:


ifstatement is: org.modellwerk.erpm.mState.impl.WFIfStatementImpl@1a4c5b4 

I WAS EXPANDED
 


ifstatement is: org.modellwerk.erpm.mState.impl.WFIfStatementImpl@6504bc 

I WAS EXPANDED
 


ifstatement is: null 

I WAS EXPANDED
 


ifstatement is: null 

I WAS EXPANDED


Thanks for your help,
Dan
Re: Strange behaviour of EXPAND statement [message #531786 is a reply to message #531777] Thu, 06 May 2010 08:20 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hello, seems the behavour has changed. so you have to add the if.
I don't know what is the expected behavoiour so you may file a bug.


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Thu, 06 May 2010 08:36]

Report message to a moderator

Previous Topic:[XPand] Passing context / parameters through expansions
Next Topic:[Acceleo] Sequence Diagram to text
Goto Forum:
  


Current Time: Thu Mar 28 09:12:15 GMT 2024

Powered by FUDForum. Page generated in 0.02233 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top