1 11 12 package org.eclipse.jdt.core.dom; 13 14 import java.util.ArrayList ; 15 import java.util.List ; 16 17 41 public class EnumConstantDeclaration extends BodyDeclaration { 42 43 46 public static final ChildPropertyDescriptor JAVADOC_PROPERTY = 47 internalJavadocPropertyFactory(EnumConstantDeclaration.class); 48 49 52 public static final ChildListPropertyDescriptor MODIFIERS2_PROPERTY = 53 internalModifiers2PropertyFactory(EnumConstantDeclaration.class); 54 55 58 public static final ChildPropertyDescriptor NAME_PROPERTY = 59 new ChildPropertyDescriptor(EnumConstantDeclaration.class, "name", SimpleName.class, MANDATORY, NO_CYCLE_RISK); 61 64 public static final ChildListPropertyDescriptor ARGUMENTS_PROPERTY = 65 new ChildListPropertyDescriptor(EnumConstantDeclaration.class, "arguments", Expression.class, NO_CYCLE_RISK); 67 70 public static final ChildPropertyDescriptor ANONYMOUS_CLASS_DECLARATION_PROPERTY = 71 new ChildPropertyDescriptor(EnumConstantDeclaration.class, "anonymousClassDeclaration", AnonymousClassDeclaration.class, OPTIONAL, CYCLE_RISK); 73 78 private static final List PROPERTY_DESCRIPTORS; 79 80 static { 81 List properyList = new ArrayList (6); 82 createPropertyList(EnumConstantDeclaration.class, properyList); 83 addProperty(JAVADOC_PROPERTY, properyList); 84 addProperty(MODIFIERS2_PROPERTY, properyList); 85 addProperty(NAME_PROPERTY, properyList); 86 addProperty(ARGUMENTS_PROPERTY, properyList); 87 addProperty(ANONYMOUS_CLASS_DECLARATION_PROPERTY, properyList); 88 PROPERTY_DESCRIPTORS = reapPropertyList(properyList); 89 } 90 91 101 public static List propertyDescriptors(int apiLevel) { 102 return PROPERTY_DESCRIPTORS; 103 } 104 105 109 private SimpleName constantName = null; 110 111 115 private ASTNode.NodeList arguments = 116 new ASTNode.NodeList(ARGUMENTS_PROPERTY); 117 118 122 private AnonymousClassDeclaration optionalAnonymousClassDeclaration = null; 123 124 137 EnumConstantDeclaration(AST ast) { 138 super(ast); 139 unsupportedIn2(); 140 } 141 142 145 final List internalStructuralPropertiesForType(int apiLevel) { 146 return propertyDescriptors(apiLevel); 147 } 148 149 152 final ASTNode internalGetSetChildProperty(ChildPropertyDescriptor property, boolean get, ASTNode child) { 153 if (property == JAVADOC_PROPERTY) { 154 if (get) { 155 return getJavadoc(); 156 } else { 157 setJavadoc((Javadoc) child); 158 return null; 159 } 160 } 161 if (property == NAME_PROPERTY) { 162 if (get) { 163 return getName(); 164 } else { 165 setName((SimpleName) child); 166 return null; 167 } 168 } 169 if (property == ANONYMOUS_CLASS_DECLARATION_PROPERTY) { 170 if (get) { 171 return getAnonymousClassDeclaration(); 172 } else { 173 setAnonymousClassDeclaration((AnonymousClassDeclaration) child); 174 return null; 175 } 176 } 177 return super.internalGetSetChildProperty(property, get, child); 179 } 180 181 184 final List internalGetChildListProperty(ChildListPropertyDescriptor property) { 185 if (property == MODIFIERS2_PROPERTY) { 186 return modifiers(); 187 } 188 if (property == ARGUMENTS_PROPERTY) { 189 return arguments(); 190 } 191 return super.internalGetChildListProperty(property); 193 } 194 195 198 final ChildPropertyDescriptor internalJavadocProperty() { 199 return JAVADOC_PROPERTY; 200 } 201 202 205 final ChildListPropertyDescriptor internalModifiers2Property() { 206 return MODIFIERS2_PROPERTY; 207 } 208 209 212 final SimplePropertyDescriptor internalModifiersProperty() { 213 return null; 215 } 216 217 220 final int getNodeType0() { 221 return ENUM_CONSTANT_DECLARATION; 222 } 223 224 227 ASTNode clone0(AST target) { 228 EnumConstantDeclaration result = new EnumConstantDeclaration(target); 229 result.setSourceRange(this.getStartPosition(), this.getLength()); 230 result.setJavadoc( 231 (Javadoc) ASTNode.copySubtree(target, getJavadoc())); 232 result.modifiers().addAll(ASTNode.copySubtrees(target, modifiers())); 233 result.setName((SimpleName) getName().clone(target)); 234 result.arguments().addAll(ASTNode.copySubtrees(target, arguments())); 235 result.setAnonymousClassDeclaration( 236 (AnonymousClassDeclaration) ASTNode.copySubtree(target, getAnonymousClassDeclaration())); 237 return result; 238 } 239 240 243 final boolean subtreeMatch0(ASTMatcher matcher, Object other) { 244 return matcher.match(this, other); 246 } 247 248 251 void accept0(ASTVisitor visitor) { 252 boolean visitChildren = visitor.visit(this); 253 if (visitChildren) { 254 acceptChild(visitor, getJavadoc()); 256 acceptChildren(visitor, this.modifiers); 257 acceptChild(visitor, getName()); 258 acceptChildren(visitor, this.arguments); 259 acceptChild(visitor, getAnonymousClassDeclaration()); 260 } 261 visitor.endVisit(this); 262 } 263 264 269 public SimpleName getName() { 270 if (this.constantName == null) { 271 synchronized (this) { 273 if (this.constantName == null) { 274 preLazyInit(); 275 this.constantName = new SimpleName(this.ast); 276 postLazyInit(this.constantName, NAME_PROPERTY); 277 } 278 } 279 } 280 return this.constantName; 281 } 282 283 294 public void setName(SimpleName constantName) { 295 if (constantName == null) { 296 throw new IllegalArgumentException (); 297 } 298 ASTNode oldChild = this.constantName; 299 preReplaceChild(oldChild, constantName, NAME_PROPERTY); 300 this.constantName = constantName; 301 postReplaceChild(oldChild, constantName, NAME_PROPERTY); 302 } 303 304 312 public List arguments() { 313 return this.arguments; 314 } 315 316 322 public AnonymousClassDeclaration getAnonymousClassDeclaration() { 323 return this.optionalAnonymousClassDeclaration; 324 } 325 326 333 public void setAnonymousClassDeclaration(AnonymousClassDeclaration decl) { 334 ASTNode oldChild = this.optionalAnonymousClassDeclaration; 335 preReplaceChild(oldChild, decl, ANONYMOUS_CLASS_DECLARATION_PROPERTY); 336 this.optionalAnonymousClassDeclaration = decl; 337 postReplaceChild(oldChild, decl, ANONYMOUS_CLASS_DECLARATION_PROPERTY); 338 } 339 340 351 public IMethodBinding resolveConstructorBinding() { 352 return this.ast.getBindingResolver().resolveConstructor(this); 353 } 354 355 365 public IVariableBinding resolveVariable() { 366 return this.ast.getBindingResolver().resolveVariable(this); 367 } 368 369 372 int memSize() { 373 return super.memSize() + 3 * 4; 374 } 375 376 379 int treeSize() { 380 return 381 memSize() 382 + (this.optionalDocComment == null ? 0 : getJavadoc().treeSize()) 383 + this.modifiers.listSize() 384 + (this.constantName == null ? 0 : getName().treeSize()) 385 + this.arguments.listSize() 386 + (this.optionalAnonymousClassDeclaration == null ? 0 : getAnonymousClassDeclaration().treeSize()); 387 } 388 } 389 390 | Popular Tags |