vimotest / mps-alfi

Apache License 2.0
1 stars 0 forks source link

AlfiSimplficationHelper: handle nested optional FeatureTarget Invocation #16

Open Fumapps opened 4 days ago

Fumapps commented 4 days ago

What works:

optionalRow.RowOperation();

what is simplified to

if (optionalRow != null) {
  optionalRow.RowOperation();
}

What is not correctly handled:

WriteLine(optionalRow.RowOperation());
Fumapps commented 4 days ago

This alfi.simplifyAlfiLanguage.generator case has to be extended for nested situations:

concept ExpressionStatement                                                                                                                                                                                                                                   --> <T  if ($COPY_SRC$<no target> != null) { 
  $COPY_SRC$ 
}   T> 

inheritors false                                                                                                                                                                                                                                                                                                                  
condition (genContext, node)->boolean { 
  if (genContext.step object [ node ] :ne: true && AlfSimplificationHelper.isOptionalFeatureInvocationTarget(node.expression)) { 
    genContext.step object [ node ] = true; 
    return true; 
  } 

  false; 
}