1 11 12 package org.eclipse.jdt.core.dom; 13 14 import java.util.ArrayList ; 15 import java.util.List ; 16 17 27 public class WhileStatement extends Statement { 28 29 33 public static final ChildPropertyDescriptor EXPRESSION_PROPERTY = 34 new ChildPropertyDescriptor(WhileStatement.class, "expression", Expression.class, MANDATORY, CYCLE_RISK); 36 40 public static final ChildPropertyDescriptor BODY_PROPERTY = 41 new ChildPropertyDescriptor(WhileStatement.class, "body", Statement.class, MANDATORY, CYCLE_RISK); 43 48 private static final List PROPERTY_DESCRIPTORS; 49 50 static { 51 List propertyList = new ArrayList (3); 52 createPropertyList(WhileStatement.class, propertyList); 53 addProperty(EXPRESSION_PROPERTY, propertyList); 54 addProperty(BODY_PROPERTY, propertyList); 55 PROPERTY_DESCRIPTORS = reapPropertyList(propertyList); 56 } 57 58 69 public static List propertyDescriptors(int apiLevel) { 70 return PROPERTY_DESCRIPTORS; 71 } 72 73 77 private Expression expression = null; 78 79 83 private Statement body = null; 84 85 95 WhileStatement(AST ast) { 96 super(ast); 97 } 98 99 102 final List internalStructuralPropertiesForType(int apiLevel) { 103 return propertyDescriptors(apiLevel); 104 } 105 106 109 final ASTNode internalGetSetChildProperty(ChildPropertyDescriptor property, boolean get, ASTNode child) { 110 if (property == EXPRESSION_PROPERTY) { 111 if (get) { 112 return getExpression(); 113 } else { 114 setExpression((Expression) child); 115 return null; 116 } 117 } 118 if (property == BODY_PROPERTY) { 119 if (get) { 120 return getBody(); 121 } else { 122 setBody((Statement) child); 123 return null; 124 } 125 } 126 return super.internalGetSetChildProperty(property, get, child); 128 } 129 130 133 final int getNodeType0() { 134 return WHILE_STATEMENT; 135 } 136 137 140 ASTNode clone0(AST target) { 141 WhileStatement result = new WhileStatement(target); 142 result.setSourceRange(this.getStartPosition(), this.getLength()); 143 result.copyLeadingComment(this); 144 result.setExpression((Expression) getExpression().clone(target)); 145 result.setBody((Statement) getBody().clone(target)); 146 return result; 147 } 148 149 152 final boolean subtreeMatch0(ASTMatcher matcher, Object other) { 153 return matcher.match(this, other); 155 } 156 157 160 void accept0(ASTVisitor visitor) { 161 boolean visitChildren = visitor.visit(this); 162 if (visitChildren) { 163 acceptChild(visitor, getExpression()); 165 acceptChild(visitor, getBody()); 166 } 167 visitor.endVisit(this); 168 } 169 170 175 public Expression getExpression() { 176 if (this.expression == null) { 177 synchronized (this) { 179 if (this.expression == null) { 180 preLazyInit(); 181 this.expression = new SimpleName(this.ast); 182 postLazyInit(this.expression, EXPRESSION_PROPERTY); 183 } 184 } 185 } 186 return this.expression; 187 } 188 189 200 public void setExpression(Expression expression) { 201 if (expression == null) { 202 throw new IllegalArgumentException (); 203 } 204 ASTNode oldChild = this.expression; 205 preReplaceChild(oldChild, expression, EXPRESSION_PROPERTY); 206 this.expression = expression; 207 postReplaceChild(oldChild, expression, EXPRESSION_PROPERTY); 208 } 209 210 215 public Statement getBody() { 216 if (this.body == null) { 217 synchronized (this) { 219 if (this.body == null) { 220 preLazyInit(); 221 this.body = new Block(this.ast); 222 postLazyInit(this.body, BODY_PROPERTY); 223 } 224 } 225 } 226 return this.body; 227 } 228 229 248 public void setBody(Statement statement) { 249 if (statement == null) { 250 throw new IllegalArgumentException (); 251 } 252 ASTNode oldChild = this.body; 253 preReplaceChild(oldChild, statement, BODY_PROPERTY); 254 this.body = statement; 255 postReplaceChild(oldChild, statement, BODY_PROPERTY); 256 } 257 258 261 int memSize() { 262 return super.memSize() + 2 * 4; 263 } 264 265 268 int treeSize() { 269 return 270 memSize() 271 + (this.expression == null ? 0 : getExpression().treeSize()) 272 + (this.body == null ? 0 : getBody().treeSize()); 273 } 274 } 275 276 | Popular Tags |