Class ret = expr.getKnownEgressType();
if ( ret == null ) {
// not possible to evaluate expression return value
context.getErrors().add( new DescrBuildError( context.getParentDescr(),
context.getRuleDescr(),
originalCode,
"Unable to determine the resulting type of the expression: " + d.getModifyExpression() + "\n" ) );
return;
}
if ( d.getEnd() <= 0 ) {
// not correctly parse
context.getErrors().add( new DescrBuildError( context.getParentDescr(),
context.getRuleDescr(),
originalCode,
"Incorrect syntax for expression: " + d.getModifyExpression() + "\n" ) );
return;
}
String retString = ClassUtils.canonicalName( ret );
// adding modify expression
consequence.append( "{ " );
consequence.append( retString );
consequence.append( " __obj__ = (" );
consequence.append( retString );
consequence.append( ") " );
consequence.append( d.getModifyExpression() );
consequence.append( "; " );
// the following is a hack to preserve line breaks.
String originalBlock = originalCode.substring( d.getStart() - 1,
d.getEnd() );
int end = originalBlock.indexOf( "{" );
if( end == -1 ){
// no block
context.getErrors().add( new DescrBuildError( context.getParentDescr(),
context.getRuleDescr(),
null,
"Block missing after modify" + d.getModifyExpression() + " ?\n" ) );
return;
}