Search in sources :

Example 1 with TypeArgumentContext

use of org.beetl.core.parser.BeetlParser.TypeArgumentContext in project beetl2.0 by javamonkey.

the class AntlrProgramBuilder method getClassType.

private Type getClassType(ClassOrInterfaceTypeContext ctx) {
    List<TerminalNode> list = ctx.Identifier1();
    String className = this.getID(list);
    Class cls = gt.loadClassBySimpleName(className);
    if (cls == null) {
        BeetlException ex = new BeetlException(BeetlException.TYPE_SEARCH_ERROR, className);
        ex.pushToken(this.getBTToken(ctx.getStart()));
        throw ex;
    }
    Type classType = new Type(cls);
    TypeArgumentsContext typeArgCtx = ctx.typeArguments();
    if (typeArgCtx != null) {
        List<TypeArgumentContext> listType = typeArgCtx.typeArgument();
        if (listType != null) {
            Type[] subType = new Type[listType.size()];
            int i = 0;
            for (TypeArgumentContext typeCtx : listType) {
                ClassOrInterfaceTypeContext child = typeCtx.classOrInterfaceType();
                Type type = this.getClassType(child);
                subType[i++] = type;
            }
            classType.types = subType;
        }
    }
    return classType;
}
Also used : BeetlException(org.beetl.core.exception.BeetlException) Type(org.beetl.core.statement.Type) ClassOrInterfaceTypeContext(org.beetl.core.parser.BeetlParser.ClassOrInterfaceTypeContext) TerminalNode(org.antlr.v4.runtime.tree.TerminalNode) TypeArgumentContext(org.beetl.core.parser.BeetlParser.TypeArgumentContext) TypeArgumentsContext(org.beetl.core.parser.BeetlParser.TypeArgumentsContext)

Aggregations

TerminalNode (org.antlr.v4.runtime.tree.TerminalNode)1 BeetlException (org.beetl.core.exception.BeetlException)1 ClassOrInterfaceTypeContext (org.beetl.core.parser.BeetlParser.ClassOrInterfaceTypeContext)1 TypeArgumentContext (org.beetl.core.parser.BeetlParser.TypeArgumentContext)1 TypeArgumentsContext (org.beetl.core.parser.BeetlParser.TypeArgumentsContext)1 Type (org.beetl.core.statement.Type)1