当前位置: 首页>>代码示例>>Java>>正文


Java CommonTree.getParent方法代码示例

本文整理汇总了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);
    }
}
 
开发者ID:ajoabraham,项目名称:hue,代码行数:26,代码来源:TreePatcher.java

示例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);
       }
}
 
开发者ID:ajoabraham,项目名称:hue,代码行数:34,代码来源:TreePatcher.java

示例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;
}
 
开发者ID:ajoabraham,项目名称:hue,代码行数:31,代码来源:TreePatcher.java


注:本文中的org.antlr.runtime.tree.CommonTree.getParent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。