本文整理汇总了Java中org.antlr.runtime.tree.CommonTree.getParent方法的典型用法代码示例。如果您正苦于以下问题:Java CommonTree.getParent方法的具体用法?Java CommonTree.getParent怎么用?Java CommonTree.getParent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.antlr.runtime.tree.CommonTree
的用法示例。
在下文中一共展示了CommonTree.getParent方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: recursivelyFixWindowFucntion
import org.antlr.runtime.tree.CommonTree; //导入方法依赖的package包/类
public static void recursivelyFixWindowFucntion(
CommonTree srcTree) {
if (srcTree.getChildCount() == 0) { return; }
// process node
String text = srcTree.getText();
System.out.println("Currently processed node==> " + text);
if (text.equals(PARTITION_BY)) {
return;
} else if (text.equals(ORDER_BY)) {
if (srcTree.getChildCount() == 0) {
if (srcTree.getParent() != null) {
// found a matching node
srcTree.getParent().deleteChild(srcTree.getChildIndex());
srcTree.getParent().freshenParentAndChildIndexes();
}
}
return;
}
// process children
for (Tree t : children(srcTree)) {
recursivelyFixWindowFucntion((CommonTree)t);
}
}
示例2: recursivelyPatchWindowFunction
import org.antlr.runtime.tree.CommonTree; //导入方法依赖的package包/类
private static void recursivelyPatchWindowFunction(
CommonTree srcTree,
List<String> partitionByToRemove,
List<String> orderByToRemove) {
if (srcTree.getChildCount() == 0) { return; }
// process node
if (srcTree.getText().equals(PARTITION_BY)) {
treeRemoveItem(srcTree, QNAME, partitionByToRemove);
if (srcTree.getChildCount() == 0) {
if (srcTree.getParent() != null) {
srcTree.getParent().deleteChild(srcTree.getChildIndex());
srcTree.getParent().freshenParentAndChildIndexes();
}
}
return;
} else if (srcTree.getText().equals(ORDER_BY)) {
// 20150311 ToDo: need to apply partition_by solution but order by has asc/desc to string...
treeRemoveItem(srcTree, ORDER_BY_ITEM, orderByToRemove);
if (srcTree.getChildCount() == 0) {
if (srcTree.getParent() != null) {
srcTree.getParent().deleteChild(srcTree.getChildIndex());
srcTree.getParent().freshenParentAndChildIndexes();
}
}
return;
}
// process children
for (Tree t : children(srcTree)) {
recursivelyPatchWindowFunction((CommonTree)t, partitionByToRemove, orderByToRemove);
}
}
示例3: patchTreeByString
import org.antlr.runtime.tree.CommonTree; //导入方法依赖的package包/类
public static void patchTreeByString(CommonTree tree, List<String> columns, String goal) {
if (tree.getChildCount() == 0) {
// leaf
if (columns.contains(tree.getText())) {
Tree parent = tree.getParent();
// only patch tree when it's QNAME node
if (parent.getText().equals("QNAME")) {
Tree tmpTree = createGenericNode(goal);
// remove QNAME at index 0
tmpTree.deleteChild(0);
tmpTree.setParent(tree.getParent());
parent.deleteChild(0);
parent.addChild(tmpTree);
parent.addChild(tree);
((CommonTree)tmpTree).getToken().setText(goal);
((CommonTree)tmpTree).getToken().setType(tree.getType());
}
}
return;
}
// process children
for (Tree t : children(tree)) {
patchTreeByString((CommonTree)t, columns, goal);
}
return;
}