1 11 package org.eclipse.jdt.core.dom; 12 13 import java.util.ArrayList ; 14 import java.util.List ; 15 16 39 public class AnnotationTypeMemberDeclaration extends BodyDeclaration { 40 41 44 public static final ChildPropertyDescriptor JAVADOC_PROPERTY = 45 internalJavadocPropertyFactory(AnnotationTypeMemberDeclaration.class); 46 47 50 public static final ChildListPropertyDescriptor MODIFIERS2_PROPERTY = 51 internalModifiers2PropertyFactory(AnnotationTypeMemberDeclaration.class); 52 53 56 public static final ChildPropertyDescriptor NAME_PROPERTY = 57 new ChildPropertyDescriptor(AnnotationTypeMemberDeclaration.class, "name", SimpleName.class, MANDATORY, NO_CYCLE_RISK); 59 62 public static final ChildPropertyDescriptor TYPE_PROPERTY = 63 new ChildPropertyDescriptor(AnnotationTypeMemberDeclaration.class, "type", Type.class, MANDATORY, NO_CYCLE_RISK); 65 68 public static final ChildPropertyDescriptor DEFAULT_PROPERTY = 69 new ChildPropertyDescriptor(AnnotationTypeMemberDeclaration.class, "default", Expression.class, OPTIONAL, CYCLE_RISK); 71 76 private static final List PROPERTY_DESCRIPTORS; 77 78 static { 79 List properyList = new ArrayList (6); 80 createPropertyList(AnnotationTypeMemberDeclaration.class, properyList); 81 addProperty(JAVADOC_PROPERTY, properyList); 82 addProperty(MODIFIERS2_PROPERTY, properyList); 83 addProperty(NAME_PROPERTY, properyList); 84 addProperty(TYPE_PROPERTY, properyList); 85 addProperty(DEFAULT_PROPERTY, properyList); 86 PROPERTY_DESCRIPTORS = reapPropertyList(properyList); 87 } 88 89 98 public static List propertyDescriptors(int apiLevel) { 99 return PROPERTY_DESCRIPTORS; 100 } 101 102 106 private SimpleName memberName = null; 107 108 111 private Type memberType = null; 112 113 116 private Expression optionalDefaultValue = null; 117 118 131 AnnotationTypeMemberDeclaration(AST ast) { 132 super(ast); 133 unsupportedIn2(); 134 } 135 136 139 final List internalStructuralPropertiesForType(int apiLevel) { 140 return propertyDescriptors(apiLevel); 141 } 142 143 146 final ASTNode internalGetSetChildProperty(ChildPropertyDescriptor property, boolean get, ASTNode child) { 147 if (property == JAVADOC_PROPERTY) { 148 if (get) { 149 return getJavadoc(); 150 } else { 151 setJavadoc((Javadoc) child); 152 return null; 153 } 154 } 155 if (property == NAME_PROPERTY) { 156 if (get) { 157 return getName(); 158 } else { 159 setName((SimpleName) child); 160 return null; 161 } 162 } 163 if (property == NAME_PROPERTY) { 164 if (get) { 165 return getName(); 166 } else { 167 setName((SimpleName) child); 168 return null; 169 } 170 } 171 if (property == TYPE_PROPERTY) { 172 if (get) { 173 return getType(); 174 } else { 175 setType((Type) child); 176 return null; 177 } 178 } 179 if (property == DEFAULT_PROPERTY) { 180 if (get) { 181 return getDefault(); 182 } else { 183 setDefault((Expression) child); 184 return null; 185 } 186 } 187 return super.internalGetSetChildProperty(property, get, child); 189 } 190 191 194 final List internalGetChildListProperty(ChildListPropertyDescriptor property) { 195 if (property == MODIFIERS2_PROPERTY) { 196 return modifiers(); 197 } 198 return super.internalGetChildListProperty(property); 200 } 201 202 205 final ChildPropertyDescriptor internalJavadocProperty() { 206 return JAVADOC_PROPERTY; 207 } 208 209 212 final ChildListPropertyDescriptor internalModifiers2Property() { 213 return MODIFIERS2_PROPERTY; 214 } 215 216 219 final SimplePropertyDescriptor internalModifiersProperty() { 220 return null; 222 } 223 224 227 final int getNodeType0() { 228 return ANNOTATION_TYPE_MEMBER_DECLARATION; 229 } 230 231 234 ASTNode clone0(AST target) { 235 AnnotationTypeMemberDeclaration result = new AnnotationTypeMemberDeclaration(target); 236 result.setSourceRange(this.getStartPosition(), this.getLength()); 237 result.setJavadoc( 238 (Javadoc) ASTNode.copySubtree(target, getJavadoc())); 239 result.modifiers().addAll(ASTNode.copySubtrees(target, modifiers())); 240 result.setType((Type) ASTNode.copySubtree(target, getType())); 241 result.setName((SimpleName) getName().clone(target)); 242 result.setDefault((Expression) ASTNode.copySubtree(target, getDefault())); 243 return result; 244 } 245 246 249 final boolean subtreeMatch0(ASTMatcher matcher, Object other) { 250 return matcher.match(this, other); 252 } 253 254 257 void accept0(ASTVisitor visitor) { 258 boolean visitChildren = visitor.visit(this); 259 if (visitChildren) { 260 acceptChild(visitor, getJavadoc()); 262 acceptChildren(visitor, this.modifiers); 263 acceptChild(visitor, getType()); 264 acceptChild(visitor, getName()); 265 acceptChild(visitor, getDefault()); 266 } 267 visitor.endVisit(this); 268 } 269 270 275 public SimpleName getName() { 276 if (this.memberName == null) { 277 synchronized (this) { 279 if (this.memberName == null) { 280 preLazyInit(); 281 this.memberName = new SimpleName(this.ast); 282 postLazyInit(this.memberName, NAME_PROPERTY); 283 } 284 } 285 } 286 return this.memberName; 287 } 288 289 300 public void setName(SimpleName memberName) { 301 if (memberName == null) { 302 throw new IllegalArgumentException (); 303 } 304 ASTNode oldChild = this.memberName; 305 preReplaceChild(oldChild, memberName, NAME_PROPERTY); 306 this.memberName = memberName; 307 postReplaceChild(oldChild, memberName, NAME_PROPERTY); 308 } 309 310 316 public Type getType() { 317 if (this.memberType == null) { 318 synchronized (this) { 320 if (this.memberType == null) { 321 preLazyInit(); 322 this.memberType = this.ast.newPrimitiveType(PrimitiveType.INT); 323 postLazyInit(this.memberType, TYPE_PROPERTY); 324 } 325 } 326 } 327 return this.memberType; 328 } 329 330 341 public void setType(Type type) { 342 if (type == null) { 343 throw new IllegalArgumentException (); 344 } 345 ASTNode oldChild = this.memberType; 346 preReplaceChild(oldChild, type, TYPE_PROPERTY); 347 this.memberType = type; 348 postReplaceChild(oldChild, type, TYPE_PROPERTY); 349 } 350 351 357 public Expression getDefault() { 358 return this.optionalDefaultValue; 359 } 360 361 373 public void setDefault(Expression defaultValue) { 374 ASTNode oldChild = this.optionalDefaultValue; 376 preReplaceChild(oldChild, defaultValue, DEFAULT_PROPERTY); 377 this.optionalDefaultValue = defaultValue; 378 postReplaceChild(oldChild, defaultValue, DEFAULT_PROPERTY); 379 } 380 381 392 public IMethodBinding resolveBinding() { 393 return this.ast.getBindingResolver().resolveMember(this); 394 } 395 396 399 int memSize() { 400 return super.memSize() + 3 * 4; 401 } 402 403 406 int treeSize() { 407 return 408 memSize() 409 + (this.optionalDocComment == null ? 0 : getJavadoc().treeSize()) 410 + this.modifiers.listSize() 411 + (this.memberName == null ? 0 : getName().treeSize()) 412 + (this.memberType == null ? 0 : getType().treeSize()) 413 + (this.optionalDefaultValue == null ? 0 : getDefault().treeSize()); 414 } 415 } 416 417 | Popular Tags |