Search in sources :

Example 1 with TypeReference

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

the class InternalSpelExpressionParser method maybeEatTypeReference.

private boolean maybeEatTypeReference() {
    if (peekToken(TokenKind.IDENTIFIER)) {
        Token typeName = peekToken();
        Assert.state(typeName != null, "Expected token");
        if (!"T".equals(typeName.stringValue())) {
            return false;
        }
        // It looks like a type reference but is T being used as a map key?
        Token t = takeToken();
        if (peekToken(TokenKind.RSQUARE)) {
            // looks like 'T]' (T is map key)
            push(new PropertyOrFieldReference(false, t.stringValue(), t.startPos, t.endPos));
            return true;
        }
        eatToken(TokenKind.LPAREN);
        SpelNodeImpl node = eatPossiblyQualifiedId();
        // dotted qualified id
        // Are there array dimensions?
        int dims = 0;
        while (peekToken(TokenKind.LSQUARE, true)) {
            eatToken(TokenKind.RSQUARE);
            dims++;
        }
        eatToken(TokenKind.RPAREN);
        this.constructedNodes.push(new TypeReference(typeName.startPos, typeName.endPos, node, dims));
        return true;
    }
    return false;
}
Also used : SpelNodeImpl(cn.taketoday.expression.spel.ast.SpelNodeImpl) PropertyOrFieldReference(cn.taketoday.expression.spel.ast.PropertyOrFieldReference) TypeReference(cn.taketoday.expression.spel.ast.TypeReference)

Example 2 with TypeReference

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

the class InternalSpelExpressionParser method maybeEatTypeReference.

private boolean maybeEatTypeReference() {
    if (peekToken(TokenKind.IDENTIFIER)) {
        Token typeName = peekToken();
        Assert.state(typeName != null, "Expected token");
        if (!"T".equals(typeName.stringValue())) {
            return false;
        }
        // It looks like a type reference but is T being used as a map key?
        Token t = takeToken();
        if (peekToken(TokenKind.RSQUARE)) {
            // looks like 'T]' (T is map key)
            push(new PropertyOrFieldReference(false, t.stringValue(), t.startPos, t.endPos));
            return true;
        }
        eatToken(TokenKind.LPAREN);
        SpelNodeImpl node = eatPossiblyQualifiedId();
        // dotted qualified id
        // Are there array dimensions?
        int dims = 0;
        while (peekToken(TokenKind.LSQUARE, true)) {
            eatToken(TokenKind.RSQUARE);
            dims++;
        }
        eatToken(TokenKind.RPAREN);
        this.constructedNodes.push(new TypeReference(typeName.startPos, typeName.endPos, node, dims));
        return true;
    }
    return false;
}
Also used : SpelNodeImpl(cn.taketoday.expression.spel.ast.SpelNodeImpl) PropertyOrFieldReference(cn.taketoday.expression.spel.ast.PropertyOrFieldReference) TypeReference(cn.taketoday.expression.spel.ast.TypeReference)

Aggregations

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