Search in sources :

Example 1 with MethodReference

use of cn.taketoday.expression.spel.ast.MethodReference in project today-infrastructure by TAKETODAY.

the class InternalSpelExpressionParser method maybeEatMethodOrProperty.

// This is complicated due to the support for dollars in identifiers.
// Dollars are normally separate tokens but there we want to combine
// a series of identifiers and dollars into a single identifier.
private boolean maybeEatMethodOrProperty(boolean nullSafeNavigation) {
    if (peekToken(TokenKind.IDENTIFIER)) {
        Token methodOrPropertyName = takeToken();
        SpelNodeImpl[] args = maybeEatMethodArgs();
        if (args == null) {
            // property
            push(new PropertyOrFieldReference(nullSafeNavigation, methodOrPropertyName.stringValue(), methodOrPropertyName.startPos, methodOrPropertyName.endPos));
            return true;
        }
        // method reference
        push(new MethodReference(nullSafeNavigation, methodOrPropertyName.stringValue(), methodOrPropertyName.startPos, methodOrPropertyName.endPos, args));
        // TODO what is the end position for a method reference? the name or the last arg?
        return true;
    }
    return false;
}
Also used : SpelNodeImpl(cn.taketoday.expression.spel.ast.SpelNodeImpl) MethodReference(cn.taketoday.expression.spel.ast.MethodReference) PropertyOrFieldReference(cn.taketoday.expression.spel.ast.PropertyOrFieldReference)

Example 2 with MethodReference

use of cn.taketoday.expression.spel.ast.MethodReference in project today-framework by TAKETODAY.

the class InternalSpelExpressionParser method maybeEatMethodOrProperty.

// This is complicated due to the support for dollars in identifiers.
// Dollars are normally separate tokens but there we want to combine
// a series of identifiers and dollars into a single identifier.
private boolean maybeEatMethodOrProperty(boolean nullSafeNavigation) {
    if (peekToken(TokenKind.IDENTIFIER)) {
        Token methodOrPropertyName = takeToken();
        SpelNodeImpl[] args = maybeEatMethodArgs();
        if (args == null) {
            // property
            push(new PropertyOrFieldReference(nullSafeNavigation, methodOrPropertyName.stringValue(), methodOrPropertyName.startPos, methodOrPropertyName.endPos));
            return true;
        }
        // method reference
        push(new MethodReference(nullSafeNavigation, methodOrPropertyName.stringValue(), methodOrPropertyName.startPos, methodOrPropertyName.endPos, args));
        // TODO what is the end position for a method reference? the name or the last arg?
        return true;
    }
    return false;
}
Also used : SpelNodeImpl(cn.taketoday.expression.spel.ast.SpelNodeImpl) MethodReference(cn.taketoday.expression.spel.ast.MethodReference) PropertyOrFieldReference(cn.taketoday.expression.spel.ast.PropertyOrFieldReference)

Aggregations

MethodReference (cn.taketoday.expression.spel.ast.MethodReference)2 PropertyOrFieldReference (cn.taketoday.expression.spel.ast.PropertyOrFieldReference)2 SpelNodeImpl (cn.taketoday.expression.spel.ast.SpelNodeImpl)2