001 /* This file was generated with JastAdd2 (http://jastadd.org) version R20130213 */ 002 package AST; 003 004 import java.util.HashSet; 005 import java.io.File; 006 import java.util.*; 007 import beaver.*; 008 import java.util.ArrayList; 009 import java.util.zip.*; 010 import java.io.*; 011 import java.io.FileNotFoundException; 012 import java.util.Collection; 013 /** 014 * Subclass of Modifiers for resource declarations. 015 * This subclass is added as a convenient method of making resource 016 * declarations implicitly final. 017 * @production ResourceModifiers : {@link Modifiers}; 018 * @ast node 019 * @declaredat /home/jesper/svn/JastAddJ/Java7Frontend/TryWithResources.ast:16 020 */ 021 public class ResourceModifiers extends Modifiers implements Cloneable { 022 /** 023 * @apilevel low-level 024 */ 025 public void flushCache() { 026 } 027 /** 028 * @apilevel internal 029 */ 030 public void flushCollectionCache() { 031 } 032 /** 033 * @apilevel internal 034 */ 035 @SuppressWarnings({"unchecked", "cast"}) 036 public ResourceModifiers clone() throws CloneNotSupportedException { 037 ResourceModifiers node = (ResourceModifiers)super.clone(); 038 node.isFinal_computed = false; 039 node.in$Circle(false); 040 node.is$Final(false); 041 return node; 042 } 043 /** 044 * @apilevel internal 045 */ 046 @SuppressWarnings({"unchecked", "cast"}) 047 public ResourceModifiers copy() { 048 049 try { 050 ResourceModifiers node = (ResourceModifiers) clone(); 051 node.parent = null; 052 if(children != null) 053 node.children = (ASTNode[]) children.clone(); 054 055 return node; 056 } catch (CloneNotSupportedException e) { 057 throw new Error("Error: clone not supported for " + getClass().getName()); 058 } 059 060 }/** 061 * Create a deep copy of the AST subtree at this node. 062 * The copy is dangling, i.e. has no parent. 063 * @return dangling copy of the subtree at this node 064 * @apilevel low-level 065 */ 066 @SuppressWarnings({"unchecked", "cast"}) 067 public ResourceModifiers fullCopy() { 068 069 ResourceModifiers tree = (ResourceModifiers) copy(); 070 if (children != null) { 071 for (int i = 0; i < children.length; ++i) { 072 073 ASTNode child = (ASTNode) children[i]; 074 if(child != null) { 075 child = child.fullCopy(); 076 tree.setChild(child, i); 077 } 078 } 079 } 080 return tree; 081 082 } /** 083 * @ast method 084 * 085 */ 086 public ResourceModifiers() { 087 super(); 088 089 090 } 091 /** 092 * Initializes the child array to the correct size. 093 * Initializes List and Opt nta children. 094 * @apilevel internal 095 * @ast method 096 * @ast method 097 * 098 */ 099 public void init$Children() { 100 children = new ASTNode[1]; 101 setChild(new List(), 0); 102 } 103 /** 104 * @ast method 105 * 106 */ 107 public ResourceModifiers(List<Modifier> p0) { 108 setChild(p0, 0); 109 } 110 /** 111 * @apilevel low-level 112 * @ast method 113 * 114 */ 115 protected int numChildren() { 116 return 1; 117 } 118 /** 119 * @apilevel internal 120 * @ast method 121 * 122 */ 123 public boolean mayHaveRewrite() { 124 return false; 125 } 126 /** 127 * Replaces the Modifier list. 128 * @param list The new list node to be used as the Modifier list. 129 * @apilevel high-level 130 * @ast method 131 * 132 */ 133 public void setModifierList(List<Modifier> list) { 134 setChild(list, 0); 135 } 136 /** 137 * Retrieves the number of children in the Modifier list. 138 * @return Number of children in the Modifier list. 139 * @apilevel high-level 140 * @ast method 141 * 142 */ 143 public int getNumModifier() { 144 return getModifierList().getNumChild(); 145 } 146 /** 147 * Retrieves the number of children in the Modifier list. 148 * Calling this method will not trigger rewrites.. 149 * @return Number of children in the Modifier list. 150 * @apilevel low-level 151 * @ast method 152 * 153 */ 154 public int getNumModifierNoTransform() { 155 return getModifierListNoTransform().getNumChildNoTransform(); 156 } 157 /** 158 * Retrieves the element at index {@code i} in the Modifier list.. 159 * @param i Index of the element to return. 160 * @return The element at position {@code i} in the Modifier list. 161 * @apilevel high-level 162 * @ast method 163 * 164 */ 165 @SuppressWarnings({"unchecked", "cast"}) 166 public Modifier getModifier(int i) { 167 return (Modifier)getModifierList().getChild(i); 168 } 169 /** 170 * Append an element to the Modifier list. 171 * @param node The element to append to the Modifier list. 172 * @apilevel high-level 173 * @ast method 174 * 175 */ 176 public void addModifier(Modifier node) { 177 List<Modifier> list = (parent == null || state == null) ? getModifierListNoTransform() : getModifierList(); 178 list.addChild(node); 179 } 180 /** 181 * @apilevel low-level 182 * @ast method 183 * 184 */ 185 public void addModifierNoTransform(Modifier node) { 186 List<Modifier> list = getModifierListNoTransform(); 187 list.addChild(node); 188 } 189 /** 190 * Replaces the Modifier list element at index {@code i} with the new node {@code node}. 191 * @param node The new node to replace the old list element. 192 * @param i The list index of the node to be replaced. 193 * @apilevel high-level 194 * @ast method 195 * 196 */ 197 public void setModifier(Modifier node, int i) { 198 List<Modifier> list = getModifierList(); 199 list.setChild(node, i); 200 } 201 /** 202 * Retrieves the Modifier list. 203 * @return The node representing the Modifier list. 204 * @apilevel high-level 205 * @ast method 206 * 207 */ 208 public List<Modifier> getModifiers() { 209 return getModifierList(); 210 } 211 /** 212 * Retrieves the Modifier list. 213 * <p><em>This method does not invoke AST transformations.</em></p> 214 * @return The node representing the Modifier list. 215 * @apilevel low-level 216 * @ast method 217 * 218 */ 219 public List<Modifier> getModifiersNoTransform() { 220 return getModifierListNoTransform(); 221 } 222 /** 223 * Retrieves the Modifier list. 224 * @return The node representing the Modifier list. 225 * @apilevel high-level 226 * @ast method 227 * 228 */ 229 @SuppressWarnings({"unchecked", "cast"}) 230 public List<Modifier> getModifierList() { 231 List<Modifier> list = (List<Modifier>)getChild(0); 232 list.getNumChild(); 233 return list; 234 } 235 /** 236 * Retrieves the Modifier list. 237 * <p><em>This method does not invoke AST transformations.</em></p> 238 * @return The node representing the Modifier list. 239 * @apilevel low-level 240 * @ast method 241 * 242 */ 243 @SuppressWarnings({"unchecked", "cast"}) 244 public List<Modifier> getModifierListNoTransform() { 245 return (List<Modifier>)getChildNoTransform(0); 246 } 247 /** 248 * @apilevel internal 249 */ 250 protected boolean isFinal_computed = false; 251 /** 252 * @apilevel internal 253 */ 254 protected boolean isFinal_value; 255 /** 256 * @attribute syn 257 * @aspect TryWithResources 258 * @declaredat /home/jesper/svn/JastAddJ/Java7Frontend/TryWithResources.jrag:237 259 */ 260 @SuppressWarnings({"unchecked", "cast"}) 261 public boolean isFinal() { 262 if(isFinal_computed) { 263 return isFinal_value; 264 } 265 ASTNode$State state = state(); 266 int num = state.boundariesCrossed; 267 boolean isFinal = this.is$Final(); 268 isFinal_value = isFinal_compute(); 269 if(isFinal && num == state().boundariesCrossed){ isFinal_computed = true; } 270 return isFinal_value; 271 } 272 /** 273 * @apilevel internal 274 */ 275 private boolean isFinal_compute() { return true; } 276 /** 277 * @apilevel internal 278 */ 279 public ASTNode rewriteTo() { 280 return super.rewriteTo(); 281 } 282 }