use of org.kie.dmn.feel.lang.ast.FunctionInvocationNode in project drools by kiegroup.
the class FEELParserTest method testLogicalNegation.
@Test
public void testLogicalNegation() {
String inputExpression = "not ( true )";
BaseNode neg = parse(inputExpression);
assertThat(neg, is(instanceOf(FunctionInvocationNode.class)));
assertThat(neg.getResultType(), is(BuiltInType.UNKNOWN));
assertThat(neg.getText(), is("not ( true )"));
FunctionInvocationNode not = (FunctionInvocationNode) neg;
assertThat(not.getParams().getElements().get(0), is(instanceOf(BooleanNode.class)));
assertThat(not.getParams().getElements().get(0).getResultType(), is(BuiltInType.BOOLEAN));
assertThat(not.getParams().getElements().get(0).getText(), is("true"));
}
use of org.kie.dmn.feel.lang.ast.FunctionInvocationNode in project drools by kiegroup.
the class FEELParserTest method testFunctionInvocationPositionalParams.
@Test
public void testFunctionInvocationPositionalParams() {
String inputExpression = "my.test.Function( x+10, \"foo\" )";
BaseNode functionBase = parse(inputExpression);
assertThat(functionBase, is(instanceOf(FunctionInvocationNode.class)));
assertThat(functionBase.getText(), is(inputExpression));
FunctionInvocationNode function = (FunctionInvocationNode) functionBase;
assertThat(function.getName(), is(instanceOf(QualifiedNameNode.class)));
assertThat(function.getName().getText(), is("my.test.Function"));
assertThat(function.getParams(), is(instanceOf(ListNode.class)));
assertThat(function.getParams().getElements().size(), is(2));
assertThat(function.getParams().getElements().get(0), is(instanceOf(InfixOpNode.class)));
assertThat(function.getParams().getElements().get(1), is(instanceOf(StringNode.class)));
}
use of org.kie.dmn.feel.lang.ast.FunctionInvocationNode in project drools by kiegroup.
the class FEELParserTest method testFunctionInvocationWithExpressionParameters.
@Test
public void testFunctionInvocationWithExpressionParameters() {
String inputExpression = "date and time( date(\"2016-07-29\"), time(\"19:47:53\") )";
BaseNode functionBase = parse(inputExpression);
assertThat(functionBase, is(instanceOf(FunctionInvocationNode.class)));
assertThat(functionBase.getText(), is(inputExpression));
FunctionInvocationNode function = (FunctionInvocationNode) functionBase;
assertThat(function.getName(), is(instanceOf(NameRefNode.class)));
assertThat(function.getName().getText(), is("date and time"));
assertThat(function.getParams(), is(instanceOf(ListNode.class)));
assertThat(function.getParams().getElements().size(), is(2));
assertThat(function.getParams().getElements().get(0), is(instanceOf(FunctionInvocationNode.class)));
assertThat(function.getParams().getElements().get(1), is(instanceOf(FunctionInvocationNode.class)));
}
use of org.kie.dmn.feel.lang.ast.FunctionInvocationNode in project kie-wb-common by kiegroup.
the class DMNParseServiceImpl method parseRangeValue.
private String parseRangeValue(final BaseNode baseNode) {
if (baseNode instanceof FunctionInvocationNode) {
final FunctionInvocationNode functionInvocation = (FunctionInvocationNode) baseNode;
final String functionName = functionInvocation.getName().getText();
final String functionParams = functionInvocation.getParams().getText();
return functionName + "(" + functionParams + ")";
} else {
return baseNode.getText();
}
}
use of org.kie.dmn.feel.lang.ast.FunctionInvocationNode in project kie-wb-common by kiegroup.
the class TypeStackUtils method getTypeStack.
private List<Type> getTypeStack(final ASTNode currentNode, final ASTNode nextNode, final Position position, final boolean isListOfParameters, final boolean isParentEligible) {
final List<Type> typeStack = new ArrayList<>();
if (currentNode == null) {
return typeStack;
}
final Type type = getType(currentNode);
final boolean isNextListOfParameters = currentNode instanceof FunctionInvocationNode;
final boolean isEligibleType = isEligibleType(currentNode, nextNode, position, isParentEligible) && !isListOfParameters;
if (isEligibleType) {
typeStack.add(type);
}
try {
forEach(getChildren(currentNode), (current, next) -> {
final boolean isParentEligibleType = isListOfParameters ? isParentEligible : isEligibleType;
typeStack.addAll(getTypeStack(current, next, position, isNextListOfParameters, isParentEligibleType));
});
} catch (final Exception e) {
// Ignore errors during node inspection.
}
return typeStack;
}
Aggregations