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 /** 015 * @production AnnotatedCompilationUnit : {@link CompilationUnit} ::= <span class="component">{@link Modifiers}</span>; 016 * @ast node 017 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/Annotations.ast:16 018 */ 019 public class AnnotatedCompilationUnit extends CompilationUnit implements Cloneable { 020 /** 021 * @apilevel low-level 022 */ 023 public void flushCache() { 024 } 025 /** 026 * @apilevel internal 027 */ 028 public void flushCollectionCache() { 029 } 030 /** 031 * @apilevel internal 032 */ 033 @SuppressWarnings({"unchecked", "cast"}) 034 public AnnotatedCompilationUnit clone() throws CloneNotSupportedException { 035 AnnotatedCompilationUnit node = (AnnotatedCompilationUnit)super.clone(); 036 node.in$Circle(false); 037 node.is$Final(false); 038 return node; 039 } 040 /** 041 * @apilevel internal 042 */ 043 @SuppressWarnings({"unchecked", "cast"}) 044 public AnnotatedCompilationUnit copy() { 045 046 try { 047 AnnotatedCompilationUnit node = (AnnotatedCompilationUnit) clone(); 048 node.parent = null; 049 if(children != null) 050 node.children = (ASTNode[]) children.clone(); 051 052 return node; 053 } catch (CloneNotSupportedException e) { 054 throw new Error("Error: clone not supported for " + getClass().getName()); 055 } 056 057 }/** 058 * Create a deep copy of the AST subtree at this node. 059 * The copy is dangling, i.e. has no parent. 060 * @return dangling copy of the subtree at this node 061 * @apilevel low-level 062 */ 063 @SuppressWarnings({"unchecked", "cast"}) 064 public AnnotatedCompilationUnit fullCopy() { 065 066 AnnotatedCompilationUnit tree = (AnnotatedCompilationUnit) copy(); 067 if (children != null) { 068 for (int i = 0; i < children.length; ++i) { 069 070 ASTNode child = (ASTNode) children[i]; 071 if(child != null) { 072 child = child.fullCopy(); 073 tree.setChild(child, i); 074 } 075 } 076 } 077 return tree; 078 079 } /** 080 * @ast method 081 * @aspect Annotations 082 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/Annotations.jrag:21 083 */ 084 public void nameCheck() { 085 super.nameCheck(); 086 if(!relativeName().endsWith("package-info.java")) 087 error("package annotations should be in a file package-info.java"); 088 } 089 /** 090 * @ast method 091 * @aspect Annotations 092 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/Annotations.jrag:557 093 */ 094 public void toString(StringBuffer s) { 095 getModifiers().toString(s); 096 super.toString(s); 097 } 098 /** 099 * @ast method 100 * 101 */ 102 public AnnotatedCompilationUnit() { 103 super(); 104 105 106 } 107 /** 108 * Initializes the child array to the correct size. 109 * Initializes List and Opt nta children. 110 * @apilevel internal 111 * @ast method 112 * @ast method 113 * 114 */ 115 public void init$Children() { 116 children = new ASTNode[3]; 117 setChild(new List(), 0); 118 setChild(new List(), 1); 119 } 120 /** 121 * @ast method 122 * 123 */ 124 public AnnotatedCompilationUnit(java.lang.String p0, List<ImportDecl> p1, List<TypeDecl> p2, Modifiers p3) { 125 setPackageDecl(p0); 126 setChild(p1, 0); 127 setChild(p2, 1); 128 setChild(p3, 2); 129 } 130 /** 131 * @ast method 132 * 133 */ 134 public AnnotatedCompilationUnit(beaver.Symbol p0, List<ImportDecl> p1, List<TypeDecl> p2, Modifiers p3) { 135 setPackageDecl(p0); 136 setChild(p1, 0); 137 setChild(p2, 1); 138 setChild(p3, 2); 139 } 140 /** 141 * @apilevel low-level 142 * @ast method 143 * 144 */ 145 protected int numChildren() { 146 return 3; 147 } 148 /** 149 * @apilevel internal 150 * @ast method 151 * 152 */ 153 public boolean mayHaveRewrite() { 154 return false; 155 } 156 /** 157 * Replaces the lexeme PackageDecl. 158 * @param value The new value for the lexeme PackageDecl. 159 * @apilevel high-level 160 * @ast method 161 * 162 */ 163 public void setPackageDecl(java.lang.String value) { 164 tokenjava_lang_String_PackageDecl = value; 165 } 166 /** 167 * JastAdd-internal setter for lexeme PackageDecl using the Beaver parser. 168 * @apilevel internal 169 * @ast method 170 * 171 */ 172 public void setPackageDecl(beaver.Symbol symbol) { 173 if(symbol.value != null && !(symbol.value instanceof String)) 174 throw new UnsupportedOperationException("setPackageDecl is only valid for String lexemes"); 175 tokenjava_lang_String_PackageDecl = (String)symbol.value; 176 PackageDeclstart = symbol.getStart(); 177 PackageDeclend = symbol.getEnd(); 178 } 179 /** 180 * Retrieves the value for the lexeme PackageDecl. 181 * @return The value for the lexeme PackageDecl. 182 * @apilevel high-level 183 * @ast method 184 * 185 */ 186 public java.lang.String getPackageDecl() { 187 return tokenjava_lang_String_PackageDecl != null ? tokenjava_lang_String_PackageDecl : ""; 188 } 189 /** 190 * Replaces the ImportDecl list. 191 * @param list The new list node to be used as the ImportDecl list. 192 * @apilevel high-level 193 * @ast method 194 * 195 */ 196 public void setImportDeclList(List<ImportDecl> list) { 197 setChild(list, 0); 198 } 199 /** 200 * Retrieves the number of children in the ImportDecl list. 201 * @return Number of children in the ImportDecl list. 202 * @apilevel high-level 203 * @ast method 204 * 205 */ 206 public int getNumImportDecl() { 207 return getImportDeclList().getNumChild(); 208 } 209 /** 210 * Retrieves the number of children in the ImportDecl list. 211 * Calling this method will not trigger rewrites.. 212 * @return Number of children in the ImportDecl list. 213 * @apilevel low-level 214 * @ast method 215 * 216 */ 217 public int getNumImportDeclNoTransform() { 218 return getImportDeclListNoTransform().getNumChildNoTransform(); 219 } 220 /** 221 * Retrieves the element at index {@code i} in the ImportDecl list.. 222 * @param i Index of the element to return. 223 * @return The element at position {@code i} in the ImportDecl list. 224 * @apilevel high-level 225 * @ast method 226 * 227 */ 228 @SuppressWarnings({"unchecked", "cast"}) 229 public ImportDecl getImportDecl(int i) { 230 return (ImportDecl)getImportDeclList().getChild(i); 231 } 232 /** 233 * Append an element to the ImportDecl list. 234 * @param node The element to append to the ImportDecl list. 235 * @apilevel high-level 236 * @ast method 237 * 238 */ 239 public void addImportDecl(ImportDecl node) { 240 List<ImportDecl> list = (parent == null || state == null) ? getImportDeclListNoTransform() : getImportDeclList(); 241 list.addChild(node); 242 } 243 /** 244 * @apilevel low-level 245 * @ast method 246 * 247 */ 248 public void addImportDeclNoTransform(ImportDecl node) { 249 List<ImportDecl> list = getImportDeclListNoTransform(); 250 list.addChild(node); 251 } 252 /** 253 * Replaces the ImportDecl list element at index {@code i} with the new node {@code node}. 254 * @param node The new node to replace the old list element. 255 * @param i The list index of the node to be replaced. 256 * @apilevel high-level 257 * @ast method 258 * 259 */ 260 public void setImportDecl(ImportDecl node, int i) { 261 List<ImportDecl> list = getImportDeclList(); 262 list.setChild(node, i); 263 } 264 /** 265 * Retrieves the ImportDecl list. 266 * @return The node representing the ImportDecl list. 267 * @apilevel high-level 268 * @ast method 269 * 270 */ 271 public List<ImportDecl> getImportDecls() { 272 return getImportDeclList(); 273 } 274 /** 275 * Retrieves the ImportDecl list. 276 * <p><em>This method does not invoke AST transformations.</em></p> 277 * @return The node representing the ImportDecl list. 278 * @apilevel low-level 279 * @ast method 280 * 281 */ 282 public List<ImportDecl> getImportDeclsNoTransform() { 283 return getImportDeclListNoTransform(); 284 } 285 /** 286 * Retrieves the ImportDecl list. 287 * @return The node representing the ImportDecl list. 288 * @apilevel high-level 289 * @ast method 290 * 291 */ 292 @SuppressWarnings({"unchecked", "cast"}) 293 public List<ImportDecl> getImportDeclList() { 294 List<ImportDecl> list = (List<ImportDecl>)getChild(0); 295 list.getNumChild(); 296 return list; 297 } 298 /** 299 * Retrieves the ImportDecl list. 300 * <p><em>This method does not invoke AST transformations.</em></p> 301 * @return The node representing the ImportDecl list. 302 * @apilevel low-level 303 * @ast method 304 * 305 */ 306 @SuppressWarnings({"unchecked", "cast"}) 307 public List<ImportDecl> getImportDeclListNoTransform() { 308 return (List<ImportDecl>)getChildNoTransform(0); 309 } 310 /** 311 * Replaces the TypeDecl list. 312 * @param list The new list node to be used as the TypeDecl list. 313 * @apilevel high-level 314 * @ast method 315 * 316 */ 317 public void setTypeDeclList(List<TypeDecl> list) { 318 setChild(list, 1); 319 } 320 /** 321 * Retrieves the number of children in the TypeDecl list. 322 * @return Number of children in the TypeDecl list. 323 * @apilevel high-level 324 * @ast method 325 * 326 */ 327 public int getNumTypeDecl() { 328 return getTypeDeclList().getNumChild(); 329 } 330 /** 331 * Retrieves the number of children in the TypeDecl list. 332 * Calling this method will not trigger rewrites.. 333 * @return Number of children in the TypeDecl list. 334 * @apilevel low-level 335 * @ast method 336 * 337 */ 338 public int getNumTypeDeclNoTransform() { 339 return getTypeDeclListNoTransform().getNumChildNoTransform(); 340 } 341 /** 342 * Retrieves the element at index {@code i} in the TypeDecl list.. 343 * @param i Index of the element to return. 344 * @return The element at position {@code i} in the TypeDecl list. 345 * @apilevel high-level 346 * @ast method 347 * 348 */ 349 @SuppressWarnings({"unchecked", "cast"}) 350 public TypeDecl getTypeDecl(int i) { 351 return (TypeDecl)getTypeDeclList().getChild(i); 352 } 353 /** 354 * Append an element to the TypeDecl list. 355 * @param node The element to append to the TypeDecl list. 356 * @apilevel high-level 357 * @ast method 358 * 359 */ 360 public void addTypeDecl(TypeDecl node) { 361 List<TypeDecl> list = (parent == null || state == null) ? getTypeDeclListNoTransform() : getTypeDeclList(); 362 list.addChild(node); 363 } 364 /** 365 * @apilevel low-level 366 * @ast method 367 * 368 */ 369 public void addTypeDeclNoTransform(TypeDecl node) { 370 List<TypeDecl> list = getTypeDeclListNoTransform(); 371 list.addChild(node); 372 } 373 /** 374 * Replaces the TypeDecl list element at index {@code i} with the new node {@code node}. 375 * @param node The new node to replace the old list element. 376 * @param i The list index of the node to be replaced. 377 * @apilevel high-level 378 * @ast method 379 * 380 */ 381 public void setTypeDecl(TypeDecl node, int i) { 382 List<TypeDecl> list = getTypeDeclList(); 383 list.setChild(node, i); 384 } 385 /** 386 * Retrieves the TypeDecl list. 387 * @return The node representing the TypeDecl list. 388 * @apilevel high-level 389 * @ast method 390 * 391 */ 392 public List<TypeDecl> getTypeDecls() { 393 return getTypeDeclList(); 394 } 395 /** 396 * Retrieves the TypeDecl list. 397 * <p><em>This method does not invoke AST transformations.</em></p> 398 * @return The node representing the TypeDecl list. 399 * @apilevel low-level 400 * @ast method 401 * 402 */ 403 public List<TypeDecl> getTypeDeclsNoTransform() { 404 return getTypeDeclListNoTransform(); 405 } 406 /** 407 * Retrieves the TypeDecl list. 408 * @return The node representing the TypeDecl list. 409 * @apilevel high-level 410 * @ast method 411 * 412 */ 413 @SuppressWarnings({"unchecked", "cast"}) 414 public List<TypeDecl> getTypeDeclList() { 415 List<TypeDecl> list = (List<TypeDecl>)getChild(1); 416 list.getNumChild(); 417 return list; 418 } 419 /** 420 * Retrieves the TypeDecl list. 421 * <p><em>This method does not invoke AST transformations.</em></p> 422 * @return The node representing the TypeDecl list. 423 * @apilevel low-level 424 * @ast method 425 * 426 */ 427 @SuppressWarnings({"unchecked", "cast"}) 428 public List<TypeDecl> getTypeDeclListNoTransform() { 429 return (List<TypeDecl>)getChildNoTransform(1); 430 } 431 /** 432 * Replaces the Modifiers child. 433 * @param node The new node to replace the Modifiers child. 434 * @apilevel high-level 435 * @ast method 436 * 437 */ 438 public void setModifiers(Modifiers node) { 439 setChild(node, 2); 440 } 441 /** 442 * Retrieves the Modifiers child. 443 * @return The current node used as the Modifiers child. 444 * @apilevel high-level 445 * @ast method 446 * 447 */ 448 public Modifiers getModifiers() { 449 return (Modifiers)getChild(2); 450 } 451 /** 452 * Retrieves the Modifiers child. 453 * <p><em>This method does not invoke AST transformations.</em></p> 454 * @return The current node used as the Modifiers child. 455 * @apilevel low-level 456 * @ast method 457 * 458 */ 459 public Modifiers getModifiersNoTransform() { 460 return (Modifiers)getChildNoTransform(2); 461 } 462 /** 463 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/Annotations.jrag:71 464 * @apilevel internal 465 */ 466 public boolean Define_boolean_mayUseAnnotationTarget(ASTNode caller, ASTNode child, String name) { 467 if(caller == getModifiersNoTransform()) { 468 return name.equals("PACKAGE"); 469 } 470 else { return getParent().Define_boolean_mayUseAnnotationTarget(this, caller, name); 471 } 472 } 473 /** 474 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/Annotations.jrag:552 475 * @apilevel internal 476 */ 477 public String Define_String_hostPackage(ASTNode caller, ASTNode child) { 478 if(caller == getModifiersNoTransform()) { 479 return packageName(); 480 } 481 else { return super.Define_String_hostPackage(caller, child); 482 } 483 } 484 /** 485 * @apilevel internal 486 */ 487 public ASTNode rewriteTo() { 488 return super.rewriteTo(); 489 } 490 }