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 AssertStatement extends Statement { 28 29 33 public static final ChildPropertyDescriptor EXPRESSION_PROPERTY = 34 new ChildPropertyDescriptor(AssertStatement.class, "expression", Expression.class, MANDATORY, CYCLE_RISK); 36 40 public static final ChildPropertyDescriptor MESSAGE_PROPERTY = 41 new ChildPropertyDescriptor(AssertStatement.class, "message", Expression.class, OPTIONAL, CYCLE_RISK); 43 48 private static final List PROPERTY_DESCRIPTORS; 49 50 static { 51 List properyList = new ArrayList (3); 52 createPropertyList(AssertStatement.class, properyList); 53 addProperty(EXPRESSION_PROPERTY, properyList); 54 addProperty(MESSAGE_PROPERTY, properyList); 55 PROPERTY_DESCRIPTORS = reapPropertyList(properyList); 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 Expression optionalMessageExpression = null; 83 84 94 AssertStatement(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 == MESSAGE_PROPERTY) { 118 if (get) { 119 return getMessage(); 120 } else { 121 setMessage((Expression) child); 122 return null; 123 } 124 } 125 return super.internalGetSetChildProperty(property, get, child); 127 } 128 129 132 final int getNodeType0() { 133 return ASSERT_STATEMENT; 134 } 135 136 139 ASTNode clone0(AST target) { 140 AssertStatement result = new AssertStatement(target); 141 result.setSourceRange(this.getStartPosition(), this.getLength()); 142 result.copyLeadingComment(this); 143 result.setExpression( 144 (Expression) ASTNode.copySubtree(target, getExpression())); 145 result.setMessage( 146 (Expression) ASTNode.copySubtree(target, getMessage())); 147 return result; 148 } 149 150 153 final boolean subtreeMatch0(ASTMatcher matcher, Object other) { 154 return matcher.match(this, other); 156 } 157 158 161 void accept0(ASTVisitor visitor) { 162 boolean visitChildren = visitor.visit(this); 163 if (visitChildren) { 164 acceptChild(visitor, getExpression()); 166 acceptChild(visitor, getMessage()); 167 } 168 visitor.endVisit(this); 169 } 170 171 176 public Expression getExpression() { 177 if (this.expression == null) { 178 synchronized (this) { 180 if (this.expression == null) { 181 preLazyInit(); 182 this.expression = new SimpleName(this.ast); 183 postLazyInit(this.expression, EXPRESSION_PROPERTY); 184 } 185 } 186 } 187 return expression; 188 } 189 190 201 public void setExpression(Expression expression) { 202 if (expression == null) { 203 throw new IllegalArgumentException (); 204 } 205 ASTNode oldChild = this.expression; 207 preReplaceChild(oldChild, expression, EXPRESSION_PROPERTY); 208 this.expression = expression; 209 postReplaceChild(oldChild, expression, EXPRESSION_PROPERTY); 210 } 211 212 219 public Expression getMessage() { 220 return this.optionalMessageExpression; 221 } 222 223 235 public void setMessage(Expression expression) { 236 ASTNode oldChild = this.optionalMessageExpression; 238 preReplaceChild(oldChild, expression, MESSAGE_PROPERTY); 239 this.optionalMessageExpression = expression; 240 postReplaceChild(oldChild, expression, MESSAGE_PROPERTY); 241 } 242 243 246 int memSize() { 247 return super.memSize() + 2 * 4; 248 } 249 250 253 int treeSize() { 254 return 255 memSize() 256 + (this.expression == null ? 0 : getExpression().treeSize()) 257 + (this.optionalMessageExpression == null ? 0 : getMessage().treeSize()); 258 259 } 260 } 261 262 | Popular Tags |