Ejemplo n.º 1
0
 public boolean process(Set<? extends TypeElement> annos, RoundEnvironment rEnv) {
   Trees trees = Trees.instance(processingEnv);
   Test test = new Test();
   for (Element e : rEnv.getRootElements()) {
     Tree t = trees.getTree(e);
     test.scan(t, null);
   }
   return true;
 }
Ejemplo n.º 2
0
  @Test
  public void testDepthTreeIterator() throws Exception {
    MutableTree<Integer> tree = createMockTree();

    for (TreeIterator<Integer> it = Trees.newDepthTreeIterator(tree); it.hasNext(); ) {
      final TreeNode<Integer> node = it.next();
      Assert.assertEquals(node.getDepth(), it.getDepth());
      System.out.println(it.getDepth() + " ->" + node.getValue());
    }
  }
Ejemplo n.º 3
0
  /*

  1
  ├──── 2
  │     ├──── 3
  │     │     ├──── 4
  │     │     └──── 5
  │     └───── 6
  ├──── 7
  ├──── 8
  │     ├──── 9
  │     └──── 10
  └──── 11
  	  └──── 12
  			└──── 13
  				  └──── 14
  	 */
  @Nonnull
  static MutableTree<Integer> createMockTree() {
    final MutableTree<Integer> result = Trees.newLinkedTree(1);

    MutableTreeNode<Integer> root = result.getRoot();
    MutableTreeNode<Integer> child2 = root.addChild(2);
    MutableTreeNode<Integer> child3 = child2.addChild(3);
    child3.addChild(4);
    child3.addChild(5);
    child2.addChild(6);
    root.addChild(7);
    MutableTreeNode<Integer> child8 = root.addChild(8);
    child8.addChild(9);
    child8.addChild(10);
    root.addChild(11).addChild(12).addChild(13).addChild(14);

    return result;
  }