Search in sources :

Example 1 with QueryNode

use of com.haulmont.cuba.core.sys.jpql.tree.QueryNode in project cuba by cuba-platform.

the class IdVarSelector method pre.

@Override
public Object pre(Object t) {
    if (!(t instanceof CommonTree))
        return t;
    if (t instanceof CommonErrorNode) {
        return t;
    }
    CommonTree node = (CommonTree) t;
    if (node instanceof QueryNode) {
        QueryVariableContext newCurrent = new QueryVariableContext(model, (QueryNode) node);
        if (root == null) {
            root = newCurrent;
        }
        QueryVariableContext last = stack.peekLast();
        if (last != null) {
            last.addChild(newCurrent);
        }
        stack.addLast(newCurrent);
    }
    return t;
}
Also used : CommonTree(org.antlr.runtime.tree.CommonTree) QueryNode(com.haulmont.cuba.core.sys.jpql.tree.QueryNode) QueryVariableContext(com.haulmont.cuba.core.sys.jpql.QueryVariableContext) CommonErrorNode(org.antlr.runtime.tree.CommonErrorNode)

Example 2 with QueryNode

use of com.haulmont.cuba.core.sys.jpql.tree.QueryNode in project cuba by cuba-platform.

the class IdVarSelector method post.

@Override
public Object post(Object t) {
    if (!(t instanceof CommonTree))
        return t;
    if (t instanceof CommonErrorNode) {
        return t;
    }
    CommonTree node = (CommonTree) t;
    if (node.token == null)
        return t;
    if ((node instanceof QueryNode) && node.getParent() != null && "T_CONDITION".equals(((CommonTree) node.getParent()).token.getText())) {
        stack.peekLast().setPropagateVariablesUp(false);
        return t;
    }
    if (node instanceof IdentificationVariableNode) {
        IdentificationVariableNode vnode = (IdentificationVariableNode) node;
        vnode.identifyVariableEntity(model, stack, invalidIdVarNodes);
        return t;
    }
    if (node instanceof JoinVariableNode) {
        JoinVariableNode vnode = (JoinVariableNode) node;
        vnode.identifyVariableEntity(model, stack, invalidIdVarNodes);
        return t;
    }
    return t;
}
Also used : IdentificationVariableNode(com.haulmont.cuba.core.sys.jpql.tree.IdentificationVariableNode) CommonTree(org.antlr.runtime.tree.CommonTree) QueryNode(com.haulmont.cuba.core.sys.jpql.tree.QueryNode) JoinVariableNode(com.haulmont.cuba.core.sys.jpql.tree.JoinVariableNode) CommonErrorNode(org.antlr.runtime.tree.CommonErrorNode)

Example 3 with QueryNode

use of com.haulmont.cuba.core.sys.jpql.tree.QueryNode in project cuba by cuba-platform.

the class IdVarSelector method post.

@Override
public Object post(Object t) {
    if (!(t instanceof CommonTree))
        return t;
    if (t instanceof CommonErrorNode) {
        return t;
    }
    CommonTree node = (CommonTree) t;
    if (node.token == null)
        return t;
    if ((node instanceof QueryNode) && isInWhereSubquery(node)) {
        stack.peekLast().setPropagateVariablesUp(false);
        return t;
    }
    if (node instanceof IdentificationVariableNode) {
        IdentificationVariableNode vnode = (IdentificationVariableNode) node;
        vnode.identifyVariableEntity(model, stack, invalidIdVarNodes);
        return t;
    }
    if (node instanceof BaseJoinNode) {
        BaseJoinNode vnode = (BaseJoinNode) node;
        vnode.identifyVariableEntity(model, stack, invalidIdVarNodes);
        return t;
    }
    return t;
}
Also used : IdentificationVariableNode(com.haulmont.cuba.core.sys.jpql.tree.IdentificationVariableNode) BaseJoinNode(com.haulmont.cuba.core.sys.jpql.tree.BaseJoinNode) CommonTree(org.antlr.runtime.tree.CommonTree) QueryNode(com.haulmont.cuba.core.sys.jpql.tree.QueryNode) CommonErrorNode(org.antlr.runtime.tree.CommonErrorNode)

Example 4 with QueryNode

use of com.haulmont.cuba.core.sys.jpql.tree.QueryNode in project cuba by cuba-platform.

the class IdVarSelector method pre.

@Override
public Object pre(Object t) {
    if (!(t instanceof CommonTree))
        return t;
    CommonTree node = (CommonTree) t;
    if (node instanceof QueryNode) {
        QueryVariableContext newCurrent = new QueryVariableContext(model, (QueryNode) node);
        if (root == null) {
            root = newCurrent;
        }
        QueryVariableContext last = stack.peekLast();
        if (last != null) {
            last.addChild(newCurrent);
        }
        stack.addLast(newCurrent);
    }
    return t;
}
Also used : CommonTree(org.antlr.runtime.tree.CommonTree) QueryNode(com.haulmont.cuba.core.sys.jpql.tree.QueryNode)

Aggregations

QueryNode (com.haulmont.cuba.core.sys.jpql.tree.QueryNode)4 CommonTree (org.antlr.runtime.tree.CommonTree)4 CommonErrorNode (org.antlr.runtime.tree.CommonErrorNode)3 IdentificationVariableNode (com.haulmont.cuba.core.sys.jpql.tree.IdentificationVariableNode)2 QueryVariableContext (com.haulmont.cuba.core.sys.jpql.QueryVariableContext)1 BaseJoinNode (com.haulmont.cuba.core.sys.jpql.tree.BaseJoinNode)1 JoinVariableNode (com.haulmont.cuba.core.sys.jpql.tree.JoinVariableNode)1