private static void removeASTChild(ASTNode node) { Tree parent = node.getParent(); if (parent != null) { parent.deleteChild(node.getChildIndex()); node.setParent(null); } }
@Override public Object deleteChild(Object t, int i) { return ((Tree)t).deleteChild(i); }
@Override public Object deleteChild(Object t, int i) { return ((Tree)t).deleteChild(i); }
@Override public Object deleteChild(Object t, int i) { return ((Tree)t).deleteChild(i); }
@Override public Object deleteChild(Object t, int i) { return ((Tree)t).deleteChild(i); }
@Override public Object deleteChild(Object t, int i) { return ((Tree)t).deleteChild(i); }
public Object deleteChild(Object t, int i) { return ((Tree)t).deleteChild(i); }
public boolean removeDistinct() { Tree selectedItems = queryTree.getAstSelectedItemsNode(); boolean isDistinct = "distinct".equalsIgnoreCase(selectedItems.getChild(0).getText()); if (isDistinct) { selectedItems.deleteChild(0); selectedItems.freshenParentAndChildIndexes(); } else { return false; } return true; }
t.getParent().deleteChild(t.getChildIndex()); return;
treeNode.deleteChild(childIndex);
stmtNode.deleteChild(defineNode.getChildIndex());
private void trimHavingAndOrderby(ASTNode ast, Cube innerCube) { ASTNode havingAst = HQLParser.findNodeByPath(ast, TOK_INSERT, TOK_HAVING); if (havingAst != null) { ASTNode newHavingAst = HQLParser.trimHavingAst(havingAst, innerCube.getAllFieldNames()); if (newHavingAst != null) { havingAst.getParent().setChild(havingAst.getChildIndex(), newHavingAst); } else { havingAst.getParent().deleteChild(havingAst.getChildIndex()); } } ASTNode orderByAst = HQLParser.findNodeByPath(ast, TOK_INSERT, TOK_ORDERBY); if (orderByAst != null) { ASTNode newOrderByAst = HQLParser.trimOrderByAst(orderByAst, innerCube.getAllFieldNames()); if (newOrderByAst != null) { orderByAst.getParent().setChild(orderByAst.getChildIndex(), newOrderByAst); } else { orderByAst.getParent().deleteChild(orderByAst.getChildIndex()); } } }
private void trimHavingAndOrderby(ASTNode ast, Cube innerCube) { ASTNode havingAst = HQLParser.findNodeByPath(ast, TOK_INSERT, TOK_HAVING); if (havingAst != null) { ASTNode newHavingAst = HQLParser.trimHavingAst(havingAst, innerCube.getAllFieldNames()); if (newHavingAst != null) { havingAst.getParent().setChild(havingAst.getChildIndex(), newHavingAst); } else { havingAst.getParent().deleteChild(havingAst.getChildIndex()); } } ASTNode orderByAst = HQLParser.findNodeByPath(ast, TOK_INSERT, TOK_ORDERBY); if (orderByAst != null) { ASTNode newOrderByAst = HQLParser.trimOrderByAst(orderByAst, innerCube.getAllFieldNames()); if (newOrderByAst != null) { orderByAst.getParent().setChild(orderByAst.getChildIndex(), newOrderByAst); } else { orderByAst.getParent().deleteChild(orderByAst.getChildIndex()); } } }
public void replaceWithCount(Tree node) { Tree selectedItems = queryTree.getAstSelectedItemsNode(); boolean isDistinct = "distinct".equalsIgnoreCase(selectedItems.getChild(0).getText()); if (!(isDistinct && selectedItems.getChildCount() == 2 || selectedItems.getChildCount() == 1)) throw new IllegalStateException("Cannot replace with count if multiple fields selected"); SelectedItemNode selectedItemNode; if (isDistinct) selectedItems.deleteChild(0); selectedItemNode = (SelectedItemNode) selectedItems.getChild(0); AggregateExpressionNode countNode = createCountNode(node, isDistinct); selectedItemNode.deleteChild(0); selectedItemNode.addChild(countNode); Tree orderBy = queryTree.getAstTree().getFirstChildWithType(JPA2Lexer.T_ORDER_BY); if (orderBy != null) { queryTree.getAstTree().deleteChild(orderBy.getChildIndex()); } queryTree.getAstTree().freshenParentAndChildIndexes(); }