001 /* This file was generated with JastAdd2 (http://jastadd.org) version 2.1.3 */ 002 package AST; 003 004 import java.util.*; 005 /** 006 * @ast node 007 * @production List : {@link ASTNode}; 008 009 */ 010 public class List<T extends ASTNode> extends ASTNode<T> implements Cloneable { 011 /** 012 * @apilevel internal 013 */ 014 public List<T> clone() throws CloneNotSupportedException { 015 List node = (List) super.clone(); 016 return node; 017 } 018 /** 019 * @apilevel internal 020 */ 021 public List<T> copy() { 022 try { 023 List node = (List) clone(); 024 node.parent = null; 025 if(children != null) { 026 node.children = (ASTNode[]) children.clone(); 027 } 028 return node; 029 } catch (CloneNotSupportedException e) { 030 throw new Error("Error: clone not supported for " + getClass().getName()); 031 } 032 } 033 /** 034 * Create a deep copy of the AST subtree at this node. 035 * The copy is dangling, i.e. has no parent. 036 * @return dangling copy of the subtree at this node 037 * @apilevel low-level 038 */ 039 public List<T> fullCopy() { 040 List tree = (List) copy(); 041 if (children != null) { 042 for (int i = 0; i < children.length; ++i) { 043 ASTNode child = (ASTNode) children[i]; 044 if(child != null) { 045 child = child.fullCopy(); 046 tree.setChild(child, i); 047 } 048 } 049 } 050 return tree; 051 } 052 /** 053 */ 054 public List() { 055 super(); 056 } 057 /** 058 * Initializes the child array to the correct size. 059 * Initializes List and Opt nta children. 060 * @apilevel internal 061 * @ast method 062 */ 063 public void init$Children() { 064 } 065 /** 066 */ 067 public List(T... initialChildren) { 068 children = new ASTNode[initialChildren.length]; 069 for (int i = 0; i < children.length; ++i) { 070 addChild(initialChildren[i]); 071 } 072 } 073 /** 074 */ 075 private boolean list$touched = true; 076 /** 077 */ 078 public List<T> add(T node) { 079 addChild(node); 080 return this; 081 } 082 /** 083 */ 084 public List<T> addAll(java.util.Collection<? extends T> c) { 085 for (T node : c) { 086 addChild(node); 087 } 088 return this; 089 } 090 /** 091 */ 092 public void insertChild(ASTNode node, int i) { 093 094 list$touched = true; 095 096 super.insertChild(node, i); 097 } 098 /** 099 */ 100 public void addChild(T node) { 101 102 list$touched = true; 103 104 super.addChild(node); 105 } 106 /** 107 * @apilevel low-level 108 */ 109 public void removeChild(int i) { 110 111 list$touched = true; 112 113 super.removeChild(i); 114 } 115 /** 116 */ 117 public int getNumChild() { 118 119 if (list$touched) { 120 for (int i = 0; i < getNumChildNoTransform(); i++) { 121 getChild(i); 122 } 123 list$touched = false; 124 } 125 126 return getNumChildNoTransform(); 127 } 128 /** 129 * @apilevel low-level 130 */ 131 public void flushCache() { 132 super.flushCache(); 133 } 134 /** 135 * @apilevel internal 136 */ 137 public void flushCollectionCache() { 138 super.flushCollectionCache(); 139 } 140 }