| 
| Collecting elements from called rule [message #103017] | Tue, 07 April 2009 08:03  |  | 
| Eclipse User  |  |  |  |  | Hello, 
 I am trying to create new model elements in a called rule. I read that I
 cannot collect them using 'resolveTemp()' in
 ( http://dev.eclipse.org/newslists/news.eclipse.modeling.m2m/m sg02367.html).
 Is there another way to collect these elements?
 
 
 
 I added the code of my called rules below. They are used to recursively
 create model elements (a state and a transition) for each element in a
 list.
 
 
 rule splitTransition(t_in: slco!Transition, s:
 Sequence(Sequence(slco!Statement))){
 using{
 s_head: Sequence(slco!Statement) = s.first();
 s_tail: Sequence(Sequence(slco!Statement)) = s.subSequence(1,
 s.size()-1);
 }
 to t_out: slco!Transition(
 name	<- t_in.name,
 source	<- t_in.source,
 trigger	<- t_in.trigger,
 guard	<- t_in.guard,
 effect	<- s_head
 )
 do{
 if s_tail.size() > 0
 then thisModule.splitTransitionRecurse(t_out, t_in.target, s_tail)
 else thisModule.splitTransitionEnd(t_out, t_in.target)
 endif;
 }
 }
 
 rule splitTransitionRecurse(t_in: slco!Transition, target_state:
 slco!State, s: Sequence(Sequence(slco!Statement))){
 using{
 s_head: Sequence(slco!Statement) = s.first();
 s_tail: Sequence(Sequence(slco!Statement)) = s.subSequence(1,
 s.size()-1);
 }
 to s_out: slco!State(
 incoming	<- t_in,
 outgoing	<- t1_out
 ),
 t1_out: slco!Transition(
 source		<- s_out,
 effect		<- s_head
 )
 do{
 thisModule.stateId      <- thisModule.stateId + 1;
 s_out.name              <- 'Split_State_' +
 thisModule.stateId.toString();
 thisModule.transitionId <- thisModule.transitionId + 1;
 t1_out.name             <- 'Split_Transition_' +
 thisModule.transitionId.toString();
 
 if s_tail.size() > 0
 then thisModule.splitTransitionRecurse(t1_out, t_in.target, s_tail)
 else thisModule.splitTransitionEnd(t1_out, t_in.target)
 endif;
 }
 }
 
 rule splitTransitionEnd(t_in: slco!Transition, target_state: slco!State){
 do{
 t_in.target <- target_state;
 }
 }
 |  |  |  | 
|  | 
Powered by 
FUDForum. Page generated in 0.05523 seconds