001 /* This file was generated with JastAdd2 (http://jastadd.org) version 2.1.13-12-g880e696 */ 002 package org.extendj.ast; 003 004 import java.util.HashSet; 005 import java.io.File; 006 import java.util.Set; 007 import java.util.Collections; 008 import java.util.Collection; 009 import java.util.ArrayList; 010 import beaver.*; 011 import java.util.*; 012 import java.io.ByteArrayOutputStream; 013 import java.io.PrintStream; 014 import java.lang.reflect.InvocationTargetException; 015 import java.lang.reflect.Method; 016 import org.jastadd.util.*; 017 import java.util.zip.*; 018 import java.io.*; 019 import org.jastadd.util.PrettyPrintable; 020 import org.jastadd.util.PrettyPrinter; 021 import java.io.FileNotFoundException; 022 import java.io.BufferedInputStream; 023 import java.io.DataInputStream; 024 /** 025 * @ast node 026 * @declaredat /home/jesper/git/extendj/java5/grammar/Annotations.ast:12 027 * @production ElementAnnotationValue : {@link ElementValue} ::= <span class="component">{@link Annotation}</span>; 028 029 */ 030 public class ElementAnnotationValue extends ElementValue implements Cloneable { 031 /** 032 * @aspect Java5PrettyPrint 033 * @declaredat /home/jesper/git/extendj/java5/frontend/PrettyPrint.jadd:81 034 */ 035 public void prettyPrint(PrettyPrinter out) { 036 out.print(getAnnotation()); 037 } 038 /** 039 * @aspect AnnotationsCodegen 040 * @declaredat /home/jesper/git/extendj/java5/backend/AnnotationsCodegen.jrag:280 041 */ 042 public void appendAsAttributeTo(Attribute buf) { 043 buf.u1('@'); 044 getAnnotation().appendAsAttributeTo(buf); 045 } 046 /** 047 * @declaredat ASTNode:1 048 */ 049 public ElementAnnotationValue() { 050 super(); 051 } 052 /** 053 * Initializes the child array to the correct size. 054 * Initializes List and Opt nta children. 055 * @apilevel internal 056 * @ast method 057 * @declaredat ASTNode:10 058 */ 059 public void init$Children() { 060 children = new ASTNode[1]; 061 } 062 /** 063 * @declaredat ASTNode:13 064 */ 065 public ElementAnnotationValue(Annotation p0) { 066 setChild(p0, 0); 067 } 068 /** 069 * @apilevel low-level 070 * @declaredat ASTNode:19 071 */ 072 protected int numChildren() { 073 return 1; 074 } 075 /** 076 * @apilevel internal 077 * @declaredat ASTNode:25 078 */ 079 public boolean mayHaveRewrite() { 080 return false; 081 } 082 /** 083 * @apilevel internal 084 * @declaredat ASTNode:31 085 */ 086 public void flushAttrCache() { 087 super.flushAttrCache(); 088 } 089 /** 090 * @apilevel internal 091 * @declaredat ASTNode:37 092 */ 093 public void flushCollectionCache() { 094 super.flushCollectionCache(); 095 } 096 /** 097 * @apilevel internal 098 * @declaredat ASTNode:43 099 */ 100 public void flushRewriteCache() { 101 super.flushRewriteCache(); 102 } 103 /** 104 * @apilevel internal 105 * @declaredat ASTNode:49 106 */ 107 public ElementAnnotationValue clone() throws CloneNotSupportedException { 108 ElementAnnotationValue node = (ElementAnnotationValue) super.clone(); 109 return node; 110 } 111 /** 112 * @apilevel internal 113 * @declaredat ASTNode:56 114 */ 115 public ElementAnnotationValue copy() { 116 try { 117 ElementAnnotationValue node = (ElementAnnotationValue) clone(); 118 node.parent = null; 119 if (children != null) { 120 node.children = (ASTNode[]) children.clone(); 121 } 122 return node; 123 } catch (CloneNotSupportedException e) { 124 throw new Error("Error: clone not supported for " + getClass().getName()); 125 } 126 } 127 /** 128 * Create a deep copy of the AST subtree at this node. 129 * The copy is dangling, i.e. has no parent. 130 * @return dangling copy of the subtree at this node 131 * @apilevel low-level 132 * @deprecated Please use treeCopy or treeCopyNoTransform instead 133 * @declaredat ASTNode:75 134 */ 135 @Deprecated 136 public ElementAnnotationValue fullCopy() { 137 return treeCopyNoTransform(); 138 } 139 /** 140 * Create a deep copy of the AST subtree at this node. 141 * The copy is dangling, i.e. has no parent. 142 * @return dangling copy of the subtree at this node 143 * @apilevel low-level 144 * @declaredat ASTNode:85 145 */ 146 public ElementAnnotationValue treeCopyNoTransform() { 147 ElementAnnotationValue tree = (ElementAnnotationValue) copy(); 148 if (children != null) { 149 for (int i = 0; i < children.length; ++i) { 150 ASTNode child = (ASTNode) children[i]; 151 if (child != null) { 152 child = child.treeCopyNoTransform(); 153 tree.setChild(child, i); 154 } 155 } 156 } 157 return tree; 158 } 159 /** 160 * Create a deep copy of the AST subtree at this node. 161 * The subtree of this node is traversed to trigger rewrites before copy. 162 * The copy is dangling, i.e. has no parent. 163 * @return dangling copy of the subtree at this node 164 * @apilevel low-level 165 * @declaredat ASTNode:105 166 */ 167 public ElementAnnotationValue treeCopy() { 168 doFullTraversal(); 169 return treeCopyNoTransform(); 170 } 171 /** 172 * @apilevel internal 173 * @declaredat ASTNode:112 174 */ 175 protected boolean is$Equal(ASTNode node) { 176 return super.is$Equal(node); 177 } 178 /** 179 * Replaces the Annotation child. 180 * @param node The new node to replace the Annotation child. 181 * @apilevel high-level 182 */ 183 public void setAnnotation(Annotation node) { 184 setChild(node, 0); 185 } 186 /** 187 * Retrieves the Annotation child. 188 * @return The current node used as the Annotation child. 189 * @apilevel high-level 190 */ 191 @ASTNodeAnnotation.Child(name="Annotation") 192 public Annotation getAnnotation() { 193 return (Annotation) getChild(0); 194 } 195 /** 196 * Retrieves the Annotation child. 197 * <p><em>This method does not invoke AST transformations.</em></p> 198 * @return The current node used as the Annotation child. 199 * @apilevel low-level 200 */ 201 public Annotation getAnnotationNoTransform() { 202 return (Annotation) getChildNoTransform(0); 203 } 204 /** 205 * @attribute syn 206 * @aspect Annotations 207 * @declaredat /home/jesper/git/extendj/java5/frontend/Annotations.jrag:558 208 */ 209 @ASTNodeAnnotation.Attribute 210 public boolean commensurateWithTypeDecl(TypeDecl type) { 211 { 212 return type() == type; 213 } 214 } 215 /** 216 * @attribute syn 217 * @aspect Annotations 218 * @declaredat /home/jesper/git/extendj/java5/frontend/Annotations.jrag:607 219 */ 220 @ASTNodeAnnotation.Attribute 221 public TypeDecl type() { 222 TypeDecl type_value = getAnnotation().type(); 223 224 return type_value; 225 } 226 /** 227 * @attribute inh 228 * @aspect Annotations 229 * @declaredat /home/jesper/git/extendj/java5/frontend/Annotations.jrag:504 230 */ 231 /** 232 * @attribute inh 233 * @aspect Annotations 234 * @declaredat /home/jesper/git/extendj/java5/frontend/Annotations.jrag:504 235 */ 236 @ASTNodeAnnotation.Attribute 237 public Annotation lookupAnnotation(TypeDecl typeDecl) { 238 Annotation lookupAnnotation_TypeDecl_value = getParent().Define_lookupAnnotation(this, null, typeDecl); 239 240 return lookupAnnotation_TypeDecl_value; 241 } 242 /** 243 * @declaredat /home/jesper/git/extendj/java5/frontend/Annotations.jrag:96 244 * @apilevel internal 245 */ 246 public boolean Define_mayUseAnnotationTarget(ASTNode caller, ASTNode child, String name) { 247 if (caller == getAnnotationNoTransform()) { 248 // @declaredat /home/jesper/git/extendj/java5/frontend/Annotations.jrag:122 249 return true; 250 } 251 else { 252 return getParent().Define_mayUseAnnotationTarget(this, caller, name); 253 } 254 } 255 protected boolean canDefine_mayUseAnnotationTarget(ASTNode caller, ASTNode child, String name) { 256 return true; 257 } 258 /** 259 * @declaredat /home/jesper/git/extendj/java5/frontend/Annotations.jrag:504 260 * @apilevel internal 261 */ 262 public Annotation Define_lookupAnnotation(ASTNode caller, ASTNode child, TypeDecl typeDecl) { 263 if (caller == getAnnotationNoTransform()) { 264 // @declaredat /home/jesper/git/extendj/java5/frontend/Annotations.jrag:508 265 return getAnnotation().type() == typeDecl ? getAnnotation() : lookupAnnotation(typeDecl); 266 } 267 else { 268 return getParent().Define_lookupAnnotation(this, caller, typeDecl); 269 } 270 } 271 protected boolean canDefine_lookupAnnotation(ASTNode caller, ASTNode child, TypeDecl typeDecl) { 272 return true; 273 } 274 /** 275 * @apilevel internal 276 */ 277 public ASTNode rewriteTo() { 278 return super.rewriteTo(); 279 } 280 }