Skip to content

Commit

Permalink
[BZ-1044973] fix method call unmarshalling
Browse files Browse the repository at this point in the history
(cherry picked from commit 8288ddb)
  • Loading branch information
mariofusco authored and Rikkola committed Mar 17, 2014
1 parent f464888 commit 9d26e3c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2316,11 +2316,20 @@ private void parseRhs( RuleModel m,
if ( param.length() == 0 ) {
continue;
}
String dataType = methodInfo == null ?
inferDataType( param, isJavaDialect ) :
methodInfo.getParams().get( i++ );

String dataType = null;
if (methodInfo != null) {
dataType = methodInfo.getParams().get( i++ );
} else {
dataType = boundParams.get(param);
}
if (dataType == null) {
dataType = inferDataType( param, isJavaDialect );
}

ActionFieldFunction actionFiled = new ActionFieldFunction( null, adjustParam( dataType, param, isJavaDialect ), dataType );
actionFiled.setNature( inferFieldNature( param, boundParams ) );
actionFiled.setField( methodName );
acm.addFieldValue( actionFiled );
}
}
Expand Down Expand Up @@ -2373,12 +2382,12 @@ private int inferFieldNature( String param,
if ( boundParams.keySet().contains( param ) ) {
return FieldNatureType.TYPE_VARIABLE;
}
if ( param.startsWith( "\"" ) ) {
return FieldNatureType.TYPE_LITERAL;
}
if ( param.contains( "+" ) || param.contains( "-" ) || param.contains( "*" ) || param.contains( "/" ) ) {
return FieldNatureType.TYPE_FORMULA;
}
if ( param.startsWith( "\"" ) || Character.isDigit(param.charAt(0)) ) {
return FieldNatureType.TYPE_LITERAL;
}
return FieldNatureType.TYPE_UNDEFINED;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3293,7 +3293,7 @@ public void testFunctionCalls() {
assertEquals(1,actionCallMethod1.getFieldValues().length);
assertEquals("indexOf",actionCallMethod1.getFieldValues()[0].getField());
assertEquals("s",actionCallMethod1.getFieldValues()[0].getValue());
assertEquals(2,actionCallMethod1.getFieldValues()[0].getNature());
assertEquals(FieldNatureType.TYPE_VARIABLE, actionCallMethod1.getFieldValues()[0].getNature());
assertEquals("String",actionCallMethod1.getFieldValues()[0].getType());


Expand All @@ -3304,8 +3304,8 @@ public void testFunctionCalls() {
assertEquals(1,actionCallMethod2.getFieldValues().length);
assertEquals("indexOf",actionCallMethod2.getFieldValues()[0].getField());
assertEquals("0",actionCallMethod2.getFieldValues()[0].getValue());
assertEquals(1,actionCallMethod2.getFieldValues()[0].getNature());
assertEquals("Integer",actionCallMethod2.getFieldValues()[0].getType());
assertEquals(FieldNatureType.TYPE_LITERAL, actionCallMethod2.getFieldValues()[0].getNature());
assertEquals("Numeric",actionCallMethod2.getFieldValues()[0].getType());

}

Expand Down

0 comments on commit 9d26e3c

Please sign in to comment.