/** * Wraps some node in a ReferenceExpression, so when rebuilding, the subtree will be surrounded by parens */ public static ASTReferenceExpression wrap(JexlNode node) { ASTReferenceExpression ref = new ASTReferenceExpression(ParserTreeConstants.JJTREFERENCEEXPRESSION); return children(ref, node); }
protected void setupSource(JexlNode source) { this.jjtSetParent(source.jjtGetParent()); // create the assignment using the class name wrapped in an expression JexlNode refNode1 = JexlNodeFactory.createExpression(JexlNodeFactory.createAssignment(getClass().getSimpleName(), true)); // wrap the source in an expression JexlNode refNode2 = JexlNodeFactory.createExpression(source); // wrap the assignment and source in an AND node JexlNode andNode = JexlNodeFactory.createUnwrappedAndNode(Arrays.asList(refNode1, refNode2)); // wrap the and node with an expression (see JexlNodeFactory.createAndNode) ASTReferenceExpression refExpNode1 = new ASTReferenceExpression(ParserTreeConstants.JJTREFERENCEEXPRESSION); andNode.jjtSetParent(refExpNode1); refExpNode1.jjtAddChild(andNode, 0); // and make a child of this refExpNode1.jjtSetParent(this); this.jjtAddChild(refExpNode1, 0); }
copy = new ASTTrueNode(ParserTreeConstants.JJTTRUENODE); } else if (ASTReferenceExpression.class.isAssignableFrom(clz)) { copy = new ASTReferenceExpression(ParserTreeConstants.JJTREFERENCEEXPRESSION); } else if (ASTReference.class.isAssignableFrom(clz)) { copy = new ASTReference(ParserTreeConstants.JJTREFERENCE);
/** * Wrap an ASTAndNode or ASTOrNode in parenthesis if it has more than one child. Will return itself if wrapping is unnecessary. * * @param toWrap * @return */ public static JexlNode wrap(JexlNode toWrap) { if ((toWrap instanceof ASTAndNode || toWrap instanceof ASTOrNode) && toWrap.jjtGetNumChildren() > 1) { ASTReference reference = new ASTReference(ParserTreeConstants.JJTREFERENCE); ASTReferenceExpression parens = new ASTReferenceExpression(ParserTreeConstants.JJTREFERENCEEXPRESSION); parens.jjtAddChild(toWrap, 0); toWrap.jjtSetParent(parens); reference.jjtAddChild(parens, 0); parens.jjtSetParent(reference); return reference; } return toWrap; }
/** * Creates a reference expression fro a child node * * @param child * @return */ public static JexlNode createExpression(JexlNode child) { ASTReference ref = new ASTReference(ParserTreeConstants.JJTREFERENCE); ASTReferenceExpression exp = new ASTReferenceExpression(ParserTreeConstants.JJTREFERENCEEXPRESSION); child.jjtSetParent(exp); exp.jjtAddChild(child, 0); exp.jjtSetParent(ref); ref.jjtAddChild(exp, 0); ref.jjtSetParent(child.jjtGetParent()); return ref; }
ASTReferenceExpression exp = new ASTReferenceExpression(ParserTreeConstants.JJTREFERENCEEXPRESSION);
ASTReferenceExpression expression = new ASTReferenceExpression(ParserTreeConstants.JJTREFERENCEEXPRESSION); if (null != jexlNode.jjtGetParent()) expression.image = jexlNode.jjtGetParent().image;
ASTReferenceExpression jjtn000 = new ASTReferenceExpression(JJTREFERENCEEXPRESSION); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000);