1 11 12 package org.eclipse.jdt.core.dom; 13 14 import java.util.ArrayList ; 15 import java.util.List ; 16 17 26 public class Initializer extends BodyDeclaration { 27 28 32 public static final ChildPropertyDescriptor JAVADOC_PROPERTY = 33 internalJavadocPropertyFactory(Initializer.class); 34 35 39 public static final SimplePropertyDescriptor MODIFIERS_PROPERTY = 40 internalModifiersPropertyFactory(Initializer.class); 41 42 46 public static final ChildListPropertyDescriptor MODIFIERS2_PROPERTY = 47 internalModifiers2PropertyFactory(Initializer.class); 48 49 53 public static final ChildPropertyDescriptor BODY_PROPERTY = 54 new ChildPropertyDescriptor(Initializer.class, "body", Block.class, MANDATORY, CYCLE_RISK); 56 62 private static final List PROPERTY_DESCRIPTORS_2_0; 63 64 70 private static final List PROPERTY_DESCRIPTORS_3_0; 71 72 static { 73 List properyList = new ArrayList (4); 74 createPropertyList(Initializer.class, properyList); 75 addProperty(JAVADOC_PROPERTY, properyList); 76 addProperty(MODIFIERS_PROPERTY, properyList); 77 addProperty(BODY_PROPERTY, properyList); 78 PROPERTY_DESCRIPTORS_2_0 = reapPropertyList(properyList); 79 80 properyList = new ArrayList (4); 81 createPropertyList(Initializer.class, properyList); 82 addProperty(JAVADOC_PROPERTY, properyList); 83 addProperty(MODIFIERS2_PROPERTY, properyList); 84 addProperty(BODY_PROPERTY, properyList); 85 PROPERTY_DESCRIPTORS_3_0 = reapPropertyList(properyList); 86 } 87 88 99 public static List propertyDescriptors(int apiLevel) { 100 if (apiLevel == AST.JLS2_INTERNAL) { 101 return PROPERTY_DESCRIPTORS_2_0; 102 } else { 103 return PROPERTY_DESCRIPTORS_3_0; 104 } 105 } 106 107 110 private Block body = null; 111 112 122 Initializer(AST ast) { 123 super(ast); 124 } 125 126 130 final List internalStructuralPropertiesForType(int apiLevel) { 131 return propertyDescriptors(apiLevel); 132 } 133 134 137 final int internalGetSetIntProperty(SimplePropertyDescriptor property, boolean get, int value) { 138 if (property == MODIFIERS_PROPERTY) { 139 if (get) { 140 return getModifiers(); 141 } else { 142 internalSetModifiers(value); 143 return 0; 144 } 145 } 146 return super.internalGetSetIntProperty(property, get, value); 148 } 149 150 153 final ASTNode internalGetSetChildProperty(ChildPropertyDescriptor property, boolean get, ASTNode child) { 154 if (property == JAVADOC_PROPERTY) { 155 if (get) { 156 return getJavadoc(); 157 } else { 158 setJavadoc((Javadoc) child); 159 return null; 160 } 161 } 162 if (property == BODY_PROPERTY) { 163 if (get) { 164 return getBody(); 165 } else { 166 setBody((Block) child); 167 return null; 168 } 169 } 170 return super.internalGetSetChildProperty(property, get, child); 172 } 173 174 177 final List internalGetChildListProperty(ChildListPropertyDescriptor property) { 178 if (property == MODIFIERS2_PROPERTY) { 179 return modifiers(); 180 } 181 return super.internalGetChildListProperty(property); 183 } 184 185 188 final ChildPropertyDescriptor internalJavadocProperty() { 189 return JAVADOC_PROPERTY; 190 } 191 192 195 final ChildListPropertyDescriptor internalModifiers2Property() { 196 return MODIFIERS2_PROPERTY; 197 } 198 199 202 final SimplePropertyDescriptor internalModifiersProperty() { 203 return MODIFIERS_PROPERTY; 204 } 205 206 209 final int getNodeType0() { 210 return INITIALIZER; 211 } 212 213 216 ASTNode clone0(AST target) { 217 Initializer result = new Initializer(target); 218 result.setSourceRange(this.getStartPosition(), this.getLength()); 219 if (this.ast.apiLevel == AST.JLS2_INTERNAL) { 220 result.internalSetModifiers(getModifiers()); 221 } 222 if (this.ast.apiLevel >= AST.JLS3) { 223 result.modifiers().addAll(ASTNode.copySubtrees(target, modifiers())); 224 } 225 result.setJavadoc( 226 (Javadoc) ASTNode.copySubtree(target, getJavadoc())); 227 result.setBody((Block) getBody().clone(target)); 228 return result; 229 } 230 231 234 final boolean subtreeMatch0(ASTMatcher matcher, Object other) { 235 return matcher.match(this, other); 237 } 238 239 242 void accept0(ASTVisitor visitor) { 243 boolean visitChildren = visitor.visit(this); 244 if (visitChildren) { 245 acceptChild(visitor, getJavadoc()); 246 if (this.ast.apiLevel >= AST.JLS3) { 247 acceptChildren(visitor, this.modifiers); 248 } 249 acceptChild(visitor, getBody()); 250 } 251 visitor.endVisit(this); 252 } 253 254 259 public Block getBody() { 260 if (this.body == null) { 261 synchronized (this) { 263 if (this.body == null) { 264 preLazyInit(); 265 this.body= new Block(this.ast); 266 postLazyInit(this.body, BODY_PROPERTY); 267 } 268 } 269 } 270 return this.body; 271 } 272 273 284 public void setBody(Block body) { 285 if (body == null) { 286 throw new IllegalArgumentException (); 287 } 288 ASTNode oldChild = this.body; 289 preReplaceChild(oldChild, body, BODY_PROPERTY); 290 this.body = body; 291 postReplaceChild(oldChild, body, BODY_PROPERTY); 292 } 293 294 297 int memSize() { 298 return super.memSize() + 1 * 4; 299 } 300 301 304 int treeSize() { 305 return 306 memSize() 307 + (this.optionalDocComment == null ? 0 : getJavadoc().treeSize()) 308 + (this.modifiers == null ? 0 : this.modifiers.listSize()) 309 + (this.body == null ? 0 : getBody().treeSize()); 310 } 311 } 312 313
| Popular Tags
|