public static JexlNode promote(JexlNode parent, JexlNode child) { JexlNode grandpa = parent.jjtGetParent(); if (grandpa == null) { child.parent = null; return child; } else { return swap(parent.jjtGetParent(), parent, child); } }
public static <T extends JexlNode> T swapLiterals(T operand, ASTReference literal) { JexlNode oldLiteral = findLiteral(operand); // we need the direct child of this operand (should be at most one level too deep) while (oldLiteral.jjtGetParent() != operand) { oldLiteral = oldLiteral.jjtGetParent(); } return JexlNodes.swap(operand, oldLiteral, literal); }
@Override public Object visit(ASTNRNode notEquals, Object data) { final JexlNode root = notEquals.jjtGetParent(); final JexlNode equals = children(new ASTERNode(ParserTreeConstants.JJTERNODE), children(notEquals)); swap(root, notEquals, negate(equals)); return null; }
@Override public Object visit(ASTNENode notEquals, Object data) { final JexlNode root = notEquals.jjtGetParent(); final JexlNode equals = children(new ASTEQNode(ParserTreeConstants.JJTEQNODE), children(notEquals)); swap(root, notEquals, negate(equals)); return null; }
@Override public Object visit(ASTReference node, Object data) { // if a delayed predicate, then change it to a regular reference if (ASTDelayedPredicate.instanceOf(node)) { JexlNode source = ASTDelayedPredicate.getDelayedPredicateSource(node); JexlNodes.swap(node.jjtGetParent(), node, source); return source; } else if (!ExecutableDeterminationVisitor.isExecutable(node, config, indexedFields, indexOnlyFields, nonEventFields, false, null, helper)) { super.visit(node, data); } return node; }
} else { JexlNodes.swap(lastAnd.jjtGetParent(), lastAnd, newOr);