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 * @production AnnotationMethodDecl : {@link MethodDecl} ::= <span class="component">[DefaultValue:{@link ElementValue}]</span>; 015 * @ast node 016 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/Annotations.ast:3 017 */ 018 public class AnnotationMethodDecl extends MethodDecl implements Cloneable { 019 /** 020 * @apilevel low-level 021 */ 022 public void flushCache() { 023 } 024 /** 025 * @apilevel internal 026 */ 027 public void flushCollectionCache() { 028 } 029 /** 030 * @apilevel internal 031 */ 032 @SuppressWarnings({"unchecked", "cast"}) 033 public AnnotationMethodDecl clone() throws CloneNotSupportedException { 034 AnnotationMethodDecl node = (AnnotationMethodDecl)super.clone(); 035 node.attributes_computed = false; 036 node.attributes_value = null; 037 node.in$Circle(false); 038 node.is$Final(false); 039 return node; 040 } 041 /** 042 * @apilevel internal 043 */ 044 @SuppressWarnings({"unchecked", "cast"}) 045 public AnnotationMethodDecl copy() { 046 047 try { 048 AnnotationMethodDecl node = (AnnotationMethodDecl) clone(); 049 node.parent = null; 050 if(children != null) 051 node.children = (ASTNode[]) children.clone(); 052 053 return node; 054 } catch (CloneNotSupportedException e) { 055 throw new Error("Error: clone not supported for " + getClass().getName()); 056 } 057 058 }/** 059 * Create a deep copy of the AST subtree at this node. 060 * The copy is dangling, i.e. has no parent. 061 * @return dangling copy of the subtree at this node 062 * @apilevel low-level 063 */ 064 @SuppressWarnings({"unchecked", "cast"}) 065 public AnnotationMethodDecl fullCopy() { 066 067 AnnotationMethodDecl tree = (AnnotationMethodDecl) copy(); 068 if (children != null) { 069 for (int i = 0; i < children.length; ++i) { 070 071 ASTNode child = (ASTNode) children[i]; 072 if(child != null) { 073 child = child.fullCopy(); 074 tree.setChild(child, i); 075 } 076 } 077 } 078 return tree; 079 080 } /** 081 * @ast method 082 * @aspect Annotations 083 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/Annotations.jrag:160 084 */ 085 public void typeCheck() { 086 super.typeCheck(); 087 if(hasDefaultValue() && !type().commensurateWith(getDefaultValue())) 088 error(type().typeName() + " is not commensurate with " + getDefaultValue().type().typeName()); 089 } 090 /** 091 * @ast method 092 * @aspect Annotations 093 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/Annotations.jrag:571 094 */ 095 public void toString(StringBuffer s) { 096 s.append(indent()); 097 getModifiers().toString(s); 098 getTypeAccess().toString(s); 099 s.append(" " + name() + "()"); 100 if(hasDefaultValue()) { 101 s.append(" default "); 102 getDefaultValue().toString(s); 103 } 104 s.append(";\n"); 105 } 106 /** 107 * @ast method 108 * 109 */ 110 public AnnotationMethodDecl() { 111 super(); 112 113 114 } 115 /** 116 * Initializes the child array to the correct size. 117 * Initializes List and Opt nta children. 118 * @apilevel internal 119 * @ast method 120 * @ast method 121 * 122 */ 123 public void init$Children() { 124 children = new ASTNode[6]; 125 setChild(new List(), 2); 126 setChild(new List(), 3); 127 setChild(new Opt(), 4); 128 setChild(new Opt(), 5); 129 } 130 /** 131 * @ast method 132 * 133 */ 134 public AnnotationMethodDecl(Modifiers p0, Access p1, String p2, List<ParameterDeclaration> p3, List<Access> p4, Opt<Block> p5, Opt<ElementValue> p6) { 135 setChild(p0, 0); 136 setChild(p1, 1); 137 setID(p2); 138 setChild(p3, 2); 139 setChild(p4, 3); 140 setChild(p5, 4); 141 setChild(p6, 5); 142 } 143 /** 144 * @ast method 145 * 146 */ 147 public AnnotationMethodDecl(Modifiers p0, Access p1, beaver.Symbol p2, List<ParameterDeclaration> p3, List<Access> p4, Opt<Block> p5, Opt<ElementValue> p6) { 148 setChild(p0, 0); 149 setChild(p1, 1); 150 setID(p2); 151 setChild(p3, 2); 152 setChild(p4, 3); 153 setChild(p5, 4); 154 setChild(p6, 5); 155 } 156 /** 157 * @apilevel low-level 158 * @ast method 159 * 160 */ 161 protected int numChildren() { 162 return 6; 163 } 164 /** 165 * @apilevel internal 166 * @ast method 167 * 168 */ 169 public boolean mayHaveRewrite() { 170 return false; 171 } 172 /** 173 * Replaces the Modifiers child. 174 * @param node The new node to replace the Modifiers child. 175 * @apilevel high-level 176 * @ast method 177 * 178 */ 179 public void setModifiers(Modifiers node) { 180 setChild(node, 0); 181 } 182 /** 183 * Retrieves the Modifiers child. 184 * @return The current node used as the Modifiers child. 185 * @apilevel high-level 186 * @ast method 187 * 188 */ 189 public Modifiers getModifiers() { 190 return (Modifiers)getChild(0); 191 } 192 /** 193 * Retrieves the Modifiers child. 194 * <p><em>This method does not invoke AST transformations.</em></p> 195 * @return The current node used as the Modifiers child. 196 * @apilevel low-level 197 * @ast method 198 * 199 */ 200 public Modifiers getModifiersNoTransform() { 201 return (Modifiers)getChildNoTransform(0); 202 } 203 /** 204 * Replaces the TypeAccess child. 205 * @param node The new node to replace the TypeAccess child. 206 * @apilevel high-level 207 * @ast method 208 * 209 */ 210 public void setTypeAccess(Access node) { 211 setChild(node, 1); 212 } 213 /** 214 * Retrieves the TypeAccess child. 215 * @return The current node used as the TypeAccess child. 216 * @apilevel high-level 217 * @ast method 218 * 219 */ 220 public Access getTypeAccess() { 221 return (Access)getChild(1); 222 } 223 /** 224 * Retrieves the TypeAccess child. 225 * <p><em>This method does not invoke AST transformations.</em></p> 226 * @return The current node used as the TypeAccess child. 227 * @apilevel low-level 228 * @ast method 229 * 230 */ 231 public Access getTypeAccessNoTransform() { 232 return (Access)getChildNoTransform(1); 233 } 234 /** 235 * Replaces the lexeme ID. 236 * @param value The new value for the lexeme ID. 237 * @apilevel high-level 238 * @ast method 239 * 240 */ 241 public void setID(String value) { 242 tokenString_ID = value; 243 } 244 /** 245 * JastAdd-internal setter for lexeme ID using the Beaver parser. 246 * @apilevel internal 247 * @ast method 248 * 249 */ 250 public void setID(beaver.Symbol symbol) { 251 if(symbol.value != null && !(symbol.value instanceof String)) 252 throw new UnsupportedOperationException("setID is only valid for String lexemes"); 253 tokenString_ID = (String)symbol.value; 254 IDstart = symbol.getStart(); 255 IDend = symbol.getEnd(); 256 } 257 /** 258 * Retrieves the value for the lexeme ID. 259 * @return The value for the lexeme ID. 260 * @apilevel high-level 261 * @ast method 262 * 263 */ 264 public String getID() { 265 return tokenString_ID != null ? tokenString_ID : ""; 266 } 267 /** 268 * Replaces the Parameter list. 269 * @param list The new list node to be used as the Parameter list. 270 * @apilevel high-level 271 * @ast method 272 * 273 */ 274 public void setParameterList(List<ParameterDeclaration> list) { 275 setChild(list, 2); 276 } 277 /** 278 * Retrieves the number of children in the Parameter list. 279 * @return Number of children in the Parameter list. 280 * @apilevel high-level 281 * @ast method 282 * 283 */ 284 public int getNumParameter() { 285 return getParameterList().getNumChild(); 286 } 287 /** 288 * Retrieves the number of children in the Parameter list. 289 * Calling this method will not trigger rewrites.. 290 * @return Number of children in the Parameter list. 291 * @apilevel low-level 292 * @ast method 293 * 294 */ 295 public int getNumParameterNoTransform() { 296 return getParameterListNoTransform().getNumChildNoTransform(); 297 } 298 /** 299 * Retrieves the element at index {@code i} in the Parameter list.. 300 * @param i Index of the element to return. 301 * @return The element at position {@code i} in the Parameter list. 302 * @apilevel high-level 303 * @ast method 304 * 305 */ 306 @SuppressWarnings({"unchecked", "cast"}) 307 public ParameterDeclaration getParameter(int i) { 308 return (ParameterDeclaration)getParameterList().getChild(i); 309 } 310 /** 311 * Append an element to the Parameter list. 312 * @param node The element to append to the Parameter list. 313 * @apilevel high-level 314 * @ast method 315 * 316 */ 317 public void addParameter(ParameterDeclaration node) { 318 List<ParameterDeclaration> list = (parent == null || state == null) ? getParameterListNoTransform() : getParameterList(); 319 list.addChild(node); 320 } 321 /** 322 * @apilevel low-level 323 * @ast method 324 * 325 */ 326 public void addParameterNoTransform(ParameterDeclaration node) { 327 List<ParameterDeclaration> list = getParameterListNoTransform(); 328 list.addChild(node); 329 } 330 /** 331 * Replaces the Parameter list element at index {@code i} with the new node {@code node}. 332 * @param node The new node to replace the old list element. 333 * @param i The list index of the node to be replaced. 334 * @apilevel high-level 335 * @ast method 336 * 337 */ 338 public void setParameter(ParameterDeclaration node, int i) { 339 List<ParameterDeclaration> list = getParameterList(); 340 list.setChild(node, i); 341 } 342 /** 343 * Retrieves the Parameter list. 344 * @return The node representing the Parameter list. 345 * @apilevel high-level 346 * @ast method 347 * 348 */ 349 public List<ParameterDeclaration> getParameters() { 350 return getParameterList(); 351 } 352 /** 353 * Retrieves the Parameter list. 354 * <p><em>This method does not invoke AST transformations.</em></p> 355 * @return The node representing the Parameter list. 356 * @apilevel low-level 357 * @ast method 358 * 359 */ 360 public List<ParameterDeclaration> getParametersNoTransform() { 361 return getParameterListNoTransform(); 362 } 363 /** 364 * Retrieves the Parameter list. 365 * @return The node representing the Parameter list. 366 * @apilevel high-level 367 * @ast method 368 * 369 */ 370 @SuppressWarnings({"unchecked", "cast"}) 371 public List<ParameterDeclaration> getParameterList() { 372 List<ParameterDeclaration> list = (List<ParameterDeclaration>)getChild(2); 373 list.getNumChild(); 374 return list; 375 } 376 /** 377 * Retrieves the Parameter list. 378 * <p><em>This method does not invoke AST transformations.</em></p> 379 * @return The node representing the Parameter list. 380 * @apilevel low-level 381 * @ast method 382 * 383 */ 384 @SuppressWarnings({"unchecked", "cast"}) 385 public List<ParameterDeclaration> getParameterListNoTransform() { 386 return (List<ParameterDeclaration>)getChildNoTransform(2); 387 } 388 /** 389 * Replaces the Exception list. 390 * @param list The new list node to be used as the Exception list. 391 * @apilevel high-level 392 * @ast method 393 * 394 */ 395 public void setExceptionList(List<Access> list) { 396 setChild(list, 3); 397 } 398 /** 399 * Retrieves the number of children in the Exception list. 400 * @return Number of children in the Exception list. 401 * @apilevel high-level 402 * @ast method 403 * 404 */ 405 public int getNumException() { 406 return getExceptionList().getNumChild(); 407 } 408 /** 409 * Retrieves the number of children in the Exception list. 410 * Calling this method will not trigger rewrites.. 411 * @return Number of children in the Exception list. 412 * @apilevel low-level 413 * @ast method 414 * 415 */ 416 public int getNumExceptionNoTransform() { 417 return getExceptionListNoTransform().getNumChildNoTransform(); 418 } 419 /** 420 * Retrieves the element at index {@code i} in the Exception list.. 421 * @param i Index of the element to return. 422 * @return The element at position {@code i} in the Exception list. 423 * @apilevel high-level 424 * @ast method 425 * 426 */ 427 @SuppressWarnings({"unchecked", "cast"}) 428 public Access getException(int i) { 429 return (Access)getExceptionList().getChild(i); 430 } 431 /** 432 * Append an element to the Exception list. 433 * @param node The element to append to the Exception list. 434 * @apilevel high-level 435 * @ast method 436 * 437 */ 438 public void addException(Access node) { 439 List<Access> list = (parent == null || state == null) ? getExceptionListNoTransform() : getExceptionList(); 440 list.addChild(node); 441 } 442 /** 443 * @apilevel low-level 444 * @ast method 445 * 446 */ 447 public void addExceptionNoTransform(Access node) { 448 List<Access> list = getExceptionListNoTransform(); 449 list.addChild(node); 450 } 451 /** 452 * Replaces the Exception list element at index {@code i} with the new node {@code node}. 453 * @param node The new node to replace the old list element. 454 * @param i The list index of the node to be replaced. 455 * @apilevel high-level 456 * @ast method 457 * 458 */ 459 public void setException(Access node, int i) { 460 List<Access> list = getExceptionList(); 461 list.setChild(node, i); 462 } 463 /** 464 * Retrieves the Exception list. 465 * @return The node representing the Exception list. 466 * @apilevel high-level 467 * @ast method 468 * 469 */ 470 public List<Access> getExceptions() { 471 return getExceptionList(); 472 } 473 /** 474 * Retrieves the Exception list. 475 * <p><em>This method does not invoke AST transformations.</em></p> 476 * @return The node representing the Exception list. 477 * @apilevel low-level 478 * @ast method 479 * 480 */ 481 public List<Access> getExceptionsNoTransform() { 482 return getExceptionListNoTransform(); 483 } 484 /** 485 * Retrieves the Exception list. 486 * @return The node representing the Exception list. 487 * @apilevel high-level 488 * @ast method 489 * 490 */ 491 @SuppressWarnings({"unchecked", "cast"}) 492 public List<Access> getExceptionList() { 493 List<Access> list = (List<Access>)getChild(3); 494 list.getNumChild(); 495 return list; 496 } 497 /** 498 * Retrieves the Exception list. 499 * <p><em>This method does not invoke AST transformations.</em></p> 500 * @return The node representing the Exception list. 501 * @apilevel low-level 502 * @ast method 503 * 504 */ 505 @SuppressWarnings({"unchecked", "cast"}) 506 public List<Access> getExceptionListNoTransform() { 507 return (List<Access>)getChildNoTransform(3); 508 } 509 /** 510 * Replaces the optional node for the Block child. This is the {@code Opt} node containing the child Block, not the actual child! 511 * @param opt The new node to be used as the optional node for the Block child. 512 * @apilevel low-level 513 * @ast method 514 * 515 */ 516 public void setBlockOpt(Opt<Block> opt) { 517 setChild(opt, 4); 518 } 519 /** 520 * Check whether the optional Block child exists. 521 * @return {@code true} if the optional Block child exists, {@code false} if it does not. 522 * @apilevel high-level 523 * @ast method 524 * 525 */ 526 public boolean hasBlock() { 527 return getBlockOpt().getNumChild() != 0; 528 } 529 /** 530 * Retrieves the (optional) Block child. 531 * @return The Block child, if it exists. Returns {@code null} otherwise. 532 * @apilevel low-level 533 * @ast method 534 * 535 */ 536 @SuppressWarnings({"unchecked", "cast"}) 537 public Block getBlock() { 538 return (Block)getBlockOpt().getChild(0); 539 } 540 /** 541 * Replaces the (optional) Block child. 542 * @param node The new node to be used as the Block child. 543 * @apilevel high-level 544 * @ast method 545 * 546 */ 547 public void setBlock(Block node) { 548 getBlockOpt().setChild(node, 0); 549 } 550 /** 551 * @apilevel low-level 552 * @ast method 553 * 554 */ 555 @SuppressWarnings({"unchecked", "cast"}) 556 public Opt<Block> getBlockOpt() { 557 return (Opt<Block>)getChild(4); 558 } 559 /** 560 * Retrieves the optional node for child Block. This is the {@code Opt} node containing the child Block, not the actual child! 561 * <p><em>This method does not invoke AST transformations.</em></p> 562 * @return The optional node for child Block. 563 * @apilevel low-level 564 * @ast method 565 * 566 */ 567 @SuppressWarnings({"unchecked", "cast"}) 568 public Opt<Block> getBlockOptNoTransform() { 569 return (Opt<Block>)getChildNoTransform(4); 570 } 571 /** 572 * Replaces the optional node for the DefaultValue child. This is the {@code Opt} node containing the child DefaultValue, not the actual child! 573 * @param opt The new node to be used as the optional node for the DefaultValue child. 574 * @apilevel low-level 575 * @ast method 576 * 577 */ 578 public void setDefaultValueOpt(Opt<ElementValue> opt) { 579 setChild(opt, 5); 580 } 581 /** 582 * Check whether the optional DefaultValue child exists. 583 * @return {@code true} if the optional DefaultValue child exists, {@code false} if it does not. 584 * @apilevel high-level 585 * @ast method 586 * 587 */ 588 public boolean hasDefaultValue() { 589 return getDefaultValueOpt().getNumChild() != 0; 590 } 591 /** 592 * Retrieves the (optional) DefaultValue child. 593 * @return The DefaultValue child, if it exists. Returns {@code null} otherwise. 594 * @apilevel low-level 595 * @ast method 596 * 597 */ 598 @SuppressWarnings({"unchecked", "cast"}) 599 public ElementValue getDefaultValue() { 600 return (ElementValue)getDefaultValueOpt().getChild(0); 601 } 602 /** 603 * Replaces the (optional) DefaultValue child. 604 * @param node The new node to be used as the DefaultValue child. 605 * @apilevel high-level 606 * @ast method 607 * 608 */ 609 public void setDefaultValue(ElementValue node) { 610 getDefaultValueOpt().setChild(node, 0); 611 } 612 /** 613 * @apilevel low-level 614 * @ast method 615 * 616 */ 617 @SuppressWarnings({"unchecked", "cast"}) 618 public Opt<ElementValue> getDefaultValueOpt() { 619 return (Opt<ElementValue>)getChild(5); 620 } 621 /** 622 * Retrieves the optional node for child DefaultValue. This is the {@code Opt} node containing the child DefaultValue, not the actual child! 623 * <p><em>This method does not invoke AST transformations.</em></p> 624 * @return The optional node for child DefaultValue. 625 * @apilevel low-level 626 * @ast method 627 * 628 */ 629 @SuppressWarnings({"unchecked", "cast"}) 630 public Opt<ElementValue> getDefaultValueOptNoTransform() { 631 return (Opt<ElementValue>)getChildNoTransform(5); 632 } 633 /** 634 * @apilevel internal 635 */ 636 protected boolean attributes_computed = false; 637 /** 638 * @apilevel internal 639 */ 640 protected Collection attributes_value; 641 /** 642 * @attribute syn 643 * @aspect AnnotationsCodegen 644 * @declaredat /home/jesper/svn/JastAddJ/Java1.5Backend/AnnotationsCodegen.jrag:143 645 */ 646 @SuppressWarnings({"unchecked", "cast"}) 647 public Collection attributes() { 648 if(attributes_computed) { 649 return attributes_value; 650 } 651 ASTNode$State state = state(); 652 int num = state.boundariesCrossed; 653 boolean isFinal = this.is$Final(); 654 attributes_value = attributes_compute(); 655 if(isFinal && num == state().boundariesCrossed){ attributes_computed = true; } 656 return attributes_value; 657 } 658 /** 659 * @apilevel internal 660 */ 661 private Collection attributes_compute() { 662 Collection c = super.attributes(); 663 // 4.8.19 664 if(hasDefaultValue()) { 665 Attribute attribute = new Attribute(hostType().constantPool(), "AnnotationDefault"); 666 getDefaultValue().appendAsAttributeTo(attribute); 667 c.add(attribute); 668 } 669 return c; 670 } 671 /** 672 * @apilevel internal 673 */ 674 public ASTNode rewriteTo() { 675 return super.rewriteTo(); 676 } 677 }