Package jetbrick.template.parser.grammer.JetTemplateParser

Examples of jetbrick.template.parser.grammer.JetTemplateParser.Expression_listContext


        return scopeCode.createLineCode(source);
    }

    @Override
    public Code visitInclude_directive(Include_directiveContext ctx) {
        Expression_listContext expression_list = ctx.expression_list();
        SegmentListCode childrenCode = (SegmentListCode) expression_list.accept(this);
        if (childrenCode.size() > 2) {
            throw reportError("Arguments mismatch for #include directive.", ctx);
        }

        // argument 1: file
        SegmentCode fileCode = childrenCode.getChild(0);
        ExpressionContext fileExpression = expression_list.expression(0);
        if (!String.class.equals(fileCode.getKlass())) {
            throw reportError("Type mismatch: the first argument cannot convert from " + fileCode.getKlassName() + " to String", fileExpression);
        }

        // argument 2: parameters
        SegmentCode parametersCode = null;
        if (childrenCode.size() > 1) {
            parametersCode = childrenCode.getChild(1);
            if (!(Map.class.equals(parametersCode.getKlass()))) {
                throw reportError("Type mismatch: the second argument cannot convert from " + parametersCode.getKlassName() + " to Map", expression_list.expression(1));
            }
        }

        // 如果 file 是常量,那么进行 file.exists() 校验
        if (fileExpression instanceof Expr_constantContext) {
View Full Code Here


        scopeCode.define(Code.CONTEXT_NAME, TypedKlass.JetContext);
        scopeCode.setBodyCode(ctx.block().accept(this)); // add body content
        scopeCode = scopeCode.pop();

        // finding tag function
        Expression_listContext expression_list = ctx.expression_list();
        SegmentListCode segmentListCode = (expression_list == null) ? SegmentListCode.EMPTY : (SegmentListCode) expression_list.accept(this);
        Class<?>[] parameterTypes = segmentListCode.getParameterTypes(JetTagContext.class);
        Method method = resolver.resolveTagMethod(name, parameterTypes);
        if (method == null) {
            throw reportError("Undefined tag definition: " + getMethodSignature(name, parameterTypes), ctx);
        }
View Full Code Here

    }

    @Override
    public Code visitExpr_array_list(Expr_array_listContext ctx) {
        String source = "Collections.EMPTY_LIST";
        Expression_listContext expression_list = ctx.expression_list();
        if (expression_list != null) {
            Code code = expression_list.accept(this);
            source = "Arrays.asList(" + code.toString() + ")";
        }
        return new SegmentCode(List.class, source, ctx);
    }
View Full Code Here

    }

    @Override
    public Code visitExpr_method_invocation(Expr_method_invocationContext ctx) {
        // 处理参数
        Expression_listContext expression_list = ctx.expression_list();
        SegmentListCode segmentListCode = (expression_list == null) ? SegmentListCode.EMPTY : (SegmentListCode) expression_list.accept(this);
        Class<?>[] parameterTypes = segmentListCode.getParameterTypes();

        // 查找方法
        SegmentCode code = (SegmentCode) ctx.expression().accept(this);
        assert_not_null_constantContext(code.getNode());
View Full Code Here

    }

    @Override
    public Code visitExpr_function_call(Expr_function_callContext ctx) {
        // 处理参数
        Expression_listContext expression_list = ctx.expression_list();
        SegmentListCode segmentListCode = (expression_list == null) ? SegmentListCode.EMPTY : (SegmentListCode) expression_list.accept(this);
        Class<?>[] parameterTypes = segmentListCode.getParameterTypes();

        // 查找方法
        String name = ctx.IDENTIFIER().getText();
View Full Code Here

        if (beanClass == null) {
            throw reportError("java.lang.ClassNotFoundException: " + typeName, static_type_name_code.getNode());
        }

        // 处理参数
        Expression_listContext expression_list = ctx.expression_list();
        SegmentListCode segmentListCode = (expression_list == null) ? SegmentListCode.EMPTY : (SegmentListCode) expression_list.accept(this);
        Class<?>[] parameterTypes = segmentListCode.getParameterTypes();

        Method method = resolver.resolveStaticMethod(beanClass, name, parameterTypes);
        if (method == null) {
            throw reportError("The static method " + getMethodSignature(name, parameterTypes) + " is undefined for the type " + beanClass.getName(), ctx.IDENTIFIER());
View Full Code Here

    @Override
    public Code visitExpr_new_object(Expr_new_objectContext ctx) {
        SegmentCode code = (SegmentCode) ctx.type().accept(this);

        Expression_listContext expression_list = ctx.expression_list();
        SegmentListCode segmentListCode = (expression_list == null) ? SegmentListCode.EMPTY : (SegmentListCode) expression_list.accept(this);
        Class<?>[] parameterTypes = segmentListCode.getParameterTypes();

        // 查找对应的构造函数
        Class<?> beanClass = code.getKlass();
        Constructor<?> constructor = resolver.resolveConstructor(beanClass, parameterTypes);
View Full Code Here

TOP

Related Classes of jetbrick.template.parser.grammer.JetTemplateParser.Expression_listContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.