use of org.kie.dmn.feel.lang.ast.QualifiedNameNode in project drools by kiegroup.
the class ASTBuilderVisitor method getFunctionName.
private String getFunctionName(BaseNode name) {
String functionName = null;
if (name instanceof NameRefNode) {
// simple name
functionName = name.getText();
} else {
QualifiedNameNode qn = (QualifiedNameNode) name;
functionName = qn.getParts().stream().map(p -> p.getText()).collect(Collectors.joining(" "));
}
return functionName;
}
use of org.kie.dmn.feel.lang.ast.QualifiedNameNode in project drools by kiegroup.
the class FEELParserTest method testQualifiedName.
@Test
public void testQualifiedName() {
String inputExpression = "My Person.Full Name";
MapBackedType personType = new MapBackedType("Person", mapOf(entry("Full Name", BuiltInType.STRING), entry("Age", BuiltInType.NUMBER)));
BaseNode qualRef = parse(inputExpression, mapOf(entry("My Person", personType)));
assertThat(qualRef, is(instanceOf(QualifiedNameNode.class)));
assertThat(qualRef.getResultType(), is(BuiltInType.STRING));
List<NameRefNode> parts = ((QualifiedNameNode) qualRef).getParts();
// `My Person` ...
assertThat(parts.get(0), is(instanceOf(NameRefNode.class)));
assertThat(parts.get(0).getResultType(), is(personType));
// ... `.Full Name`
assertThat(parts.get(1), is(instanceOf(NameRefNode.class)));
assertThat(parts.get(1).getResultType(), is(BuiltInType.STRING));
assertLocation(inputExpression, qualRef);
}
use of org.kie.dmn.feel.lang.ast.QualifiedNameNode in project drools by kiegroup.
the class FEELParserTest method testNestedContexts2.
@Test
public void testNestedContexts2() {
String inputExpression = "{ an applicant : { " + " home address : {" + " street name: \"broadway st\"," + " city : \"New York\" " + " } " + " },\n " + " street : an applicant.home address.street name \n" + "}";
BaseNode ctxbase = parse(inputExpression);
assertThat(ctxbase, is(instanceOf(ContextNode.class)));
assertThat(ctxbase.getText(), is(inputExpression));
ContextNode ctx = (ContextNode) ctxbase;
assertThat(ctx.getEntries().size(), is(2));
ContextEntryNode entry = ctx.getEntries().get(1);
assertThat(entry.getName(), is(instanceOf(NameDefNode.class)));
assertThat(entry.getResultType(), is(BuiltInType.STRING));
NameDefNode name = (NameDefNode) entry.getName();
assertThat(name.getText(), is("street"));
assertThat(entry.getValue(), is(instanceOf(QualifiedNameNode.class)));
QualifiedNameNode qnn = (QualifiedNameNode) entry.getValue();
assertThat(qnn.getParts().get(0).getText(), is("an applicant"));
assertThat(qnn.getParts().get(1).getText(), is("home address"));
assertThat(qnn.getParts().get(2).getText(), is("street name"));
}
Aggregations