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 SynchronizedStatement extends Statement { 28 29 33 public static final ChildPropertyDescriptor EXPRESSION_PROPERTY = 34 new ChildPropertyDescriptor(SynchronizedStatement.class, "expression", Expression.class, MANDATORY, CYCLE_RISK); 36 40 public static final ChildPropertyDescriptor BODY_PROPERTY = 41 new ChildPropertyDescriptor(SynchronizedStatement.class, "body", Block.class, MANDATORY, CYCLE_RISK); 43 48 private static final List PROPERTY_DESCRIPTORS; 49 50 static { 51 List propertyList = new ArrayList (3); 52 createPropertyList(SynchronizedStatement.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 82 private Block body = null; 83 84 94 SynchronizedStatement(AST ast) { 95 super(ast); 96 } 97 98 101 final List internalStructuralPropertiesForType(int apiLevel) { 102 return propertyDescriptors(apiLevel); 103 } 104 105 108 final ASTNode internalGetSetChildProperty(ChildPropertyDescriptor property, boolean get, ASTNode child) { 109 if (property == EXPRESSION_PROPERTY) { 110 if (get) { 111 return getExpression(); 112 } else { 113 setExpression((Expression) child); 114 return null; 115 } 116 } 117 if (property == BODY_PROPERTY) { 118 if (get) { 119 return getBody(); 120 } else { 121 setBody((Block) child); 122 return null; 123 } 124 } 125 return super.internalGetSetChildProperty(property, get, child); 127 } 128 129 132 final int getNodeType0() { 133 return SYNCHRONIZED_STATEMENT; 134 } 135 136 139 ASTNode clone0(AST target) { 140 SynchronizedStatement result = new SynchronizedStatement(target); 141 result.setSourceRange(this.getStartPosition(), this.getLength()); 142 result.copyLeadingComment(this); 143 result.setExpression((Expression) getExpression().clone(target)); 144 result.setBody((Block) getBody().clone(target)); 145 return result; 146 } 147 148 151 final boolean subtreeMatch0(ASTMatcher matcher, Object other) { 152 return matcher.match(this, other); 154 } 155 156 159 void accept0(ASTVisitor visitor) { 160 boolean visitChildren = visitor.visit(this); 161 if (visitChildren) { 162 acceptChild(visitor, getExpression()); 164 acceptChild(visitor, getBody()); 165 } 166 visitor.endVisit(this); 167 } 168 169 174 public Expression getExpression() { 175 if (this.expression == null) { 176 synchronized (this) { 178 if (this.expression == null) { 179 preLazyInit(); 180 this.expression = new SimpleName(this.ast); 181 postLazyInit(this.expression, EXPRESSION_PROPERTY); 182 } 183 } 184 } 185 return this.expression; 186 } 187 188 199 public void setExpression(Expression expression) { 200 if (expression == null) { 201 throw new IllegalArgumentException (); 202 } 203 ASTNode oldChild = this.expression; 204 preReplaceChild(oldChild, expression, EXPRESSION_PROPERTY); 205 this.expression = expression; 206 postReplaceChild(oldChild, expression, EXPRESSION_PROPERTY); 207 } 208 209 214 public Block getBody() { 215 if (this.body == null) { 216 synchronized (this) { 218 if (this.body == null) { 219 preLazyInit(); 220 this.body = new Block(this.ast); 221 postLazyInit(this.body, BODY_PROPERTY); 222 } 223 } 224 } 225 return this.body; 226 } 227 228 239 public void setBody(Block block) { 240 if (block == null) { 241 throw new IllegalArgumentException (); 242 } 243 ASTNode oldChild = this.body; 244 preReplaceChild(oldChild, block, BODY_PROPERTY); 245 this.body = block; 246 postReplaceChild(oldChild, block, BODY_PROPERTY); 247 } 248 249 252 int memSize() { 253 return super.memSize() + 2 * 4; 254 } 255 256 259 int treeSize() { 260 return 261 memSize() 262 + (this.expression == null ? 0 : getExpression().treeSize()) 263 + (this.body == null ? 0 : getBody().treeSize()); 264 } 265 } 266 | Popular Tags |