1 11 package org.eclipse.jdt.core.dom; 12 13 import java.util.ArrayList ; 14 import java.util.List ; 15 16 43 public class EnumDeclaration extends AbstractTypeDeclaration { 44 45 48 public static final ChildPropertyDescriptor JAVADOC_PROPERTY = 49 internalJavadocPropertyFactory(EnumDeclaration.class); 50 51 54 public static final ChildListPropertyDescriptor MODIFIERS2_PROPERTY = 55 internalModifiers2PropertyFactory(EnumDeclaration.class); 56 57 60 public static final ChildPropertyDescriptor NAME_PROPERTY = 61 internalNamePropertyFactory(EnumDeclaration.class); 62 63 66 public static final ChildListPropertyDescriptor SUPER_INTERFACE_TYPES_PROPERTY = 67 new ChildListPropertyDescriptor(EnumDeclaration.class, "superInterfaceTypes", Type.class, NO_CYCLE_RISK); 69 72 public static final ChildListPropertyDescriptor ENUM_CONSTANTS_PROPERTY = 73 new ChildListPropertyDescriptor(EnumDeclaration.class, "enumConstants", EnumConstantDeclaration.class, CYCLE_RISK); 75 78 public static final ChildListPropertyDescriptor BODY_DECLARATIONS_PROPERTY = 79 internalBodyDeclarationPropertyFactory(EnumDeclaration.class); 80 81 86 private static final List PROPERTY_DESCRIPTORS; 87 88 static { 89 List properyList = new ArrayList (6); 90 createPropertyList(EnumDeclaration.class, properyList); 91 addProperty(JAVADOC_PROPERTY, properyList); 92 addProperty(MODIFIERS2_PROPERTY, properyList); 93 addProperty(NAME_PROPERTY, properyList); 94 addProperty(SUPER_INTERFACE_TYPES_PROPERTY, properyList); 95 addProperty(ENUM_CONSTANTS_PROPERTY, properyList); 96 addProperty(BODY_DECLARATIONS_PROPERTY, properyList); 97 PROPERTY_DESCRIPTORS = reapPropertyList(properyList); 98 } 99 100 110 public static List propertyDescriptors(int apiLevel) { 111 return PROPERTY_DESCRIPTORS; 112 } 113 114 118 private ASTNode.NodeList superInterfaceTypes = 119 new ASTNode.NodeList(SUPER_INTERFACE_TYPES_PROPERTY); 120 121 126 private ASTNode.NodeList enumConstants = 127 new ASTNode.NodeList(ENUM_CONSTANTS_PROPERTY); 128 129 142 EnumDeclaration(AST ast) { 143 super(ast); 144 unsupportedIn2(); 145 } 146 147 150 final List internalStructuralPropertiesForType(int apiLevel) { 151 return propertyDescriptors(apiLevel); 152 } 153 154 157 final ASTNode internalGetSetChildProperty(ChildPropertyDescriptor property, boolean get, ASTNode child) { 158 if (property == JAVADOC_PROPERTY) { 159 if (get) { 160 return getJavadoc(); 161 } else { 162 setJavadoc((Javadoc) child); 163 return null; 164 } 165 } 166 if (property == NAME_PROPERTY) { 167 if (get) { 168 return getName(); 169 } else { 170 setName((SimpleName) child); 171 return null; 172 } 173 } 174 return super.internalGetSetChildProperty(property, get, child); 176 } 177 178 181 final List internalGetChildListProperty(ChildListPropertyDescriptor property) { 182 if (property == MODIFIERS2_PROPERTY) { 183 return modifiers(); 184 } 185 if (property == SUPER_INTERFACE_TYPES_PROPERTY) { 186 return superInterfaceTypes(); 187 } 188 if (property == ENUM_CONSTANTS_PROPERTY) { 189 return enumConstants(); 190 } 191 if (property == BODY_DECLARATIONS_PROPERTY) { 192 return bodyDeclarations(); 193 } 194 return super.internalGetChildListProperty(property); 196 } 197 198 201 final ChildPropertyDescriptor internalJavadocProperty() { 202 return JAVADOC_PROPERTY; 203 } 204 205 208 final ChildListPropertyDescriptor internalModifiers2Property() { 209 return MODIFIERS2_PROPERTY; 210 } 211 212 215 final SimplePropertyDescriptor internalModifiersProperty() { 216 return null; 218 } 219 220 223 final ChildPropertyDescriptor internalNameProperty() { 224 return NAME_PROPERTY; 225 } 226 227 230 final ChildListPropertyDescriptor internalBodyDeclarationsProperty() { 231 return BODY_DECLARATIONS_PROPERTY; 232 } 233 234 237 final int getNodeType0() { 238 return ENUM_DECLARATION; 239 } 240 241 244 ASTNode clone0(AST target) { 245 EnumDeclaration result = new EnumDeclaration(target); 246 result.setSourceRange(this.getStartPosition(), this.getLength()); 247 result.setJavadoc( 248 (Javadoc) ASTNode.copySubtree(target, getJavadoc())); 249 result.modifiers().addAll(ASTNode.copySubtrees(target, modifiers())); 250 result.setName((SimpleName) getName().clone(target)); 251 result.superInterfaceTypes().addAll( 252 ASTNode.copySubtrees(target, superInterfaceTypes())); 253 result.enumConstants().addAll( 254 ASTNode.copySubtrees(target, enumConstants())); 255 result.bodyDeclarations().addAll( 256 ASTNode.copySubtrees(target, bodyDeclarations())); 257 return result; 258 } 259 260 263 final boolean subtreeMatch0(ASTMatcher matcher, Object other) { 264 return matcher.match(this, other); 266 } 267 268 271 void accept0(ASTVisitor visitor) { 272 boolean visitChildren = visitor.visit(this); 273 if (visitChildren) { 274 acceptChild(visitor, getJavadoc()); 276 acceptChildren(visitor, this.modifiers); 277 acceptChild(visitor, getName()); 278 acceptChildren(visitor, this.superInterfaceTypes); 279 acceptChildren(visitor, this.enumConstants); 280 acceptChildren(visitor, this.bodyDeclarations); 281 } 282 visitor.endVisit(this); 283 } 284 285 292 public List superInterfaceTypes() { 293 return this.superInterfaceTypes; 294 } 295 296 303 public List enumConstants() { 304 return enumConstants; 305 } 306 307 310 ITypeBinding internalResolveBinding() { 311 return this.ast.getBindingResolver().resolveType(this); 312 } 313 314 317 int memSize() { 318 return super.memSize() + 2 * 4; 319 } 320 321 324 int treeSize() { 325 return memSize() 326 + (this.optionalDocComment == null ? 0 : getJavadoc().treeSize()) 327 + this.modifiers.listSize() 328 + (this.typeName == null ? 0 : getName().treeSize()) 329 + this.superInterfaceTypes.listSize() 330 + this.enumConstants.listSize() 331 + this.bodyDeclarations.listSize(); 332 } 333 } 334 335 | Popular Tags |