1 11 12 package org.eclipse.jdt.core.dom; 13 14 import java.util.ArrayList ; 15 import java.util.List ; 16 17 30 public class ExpressionStatement extends Statement { 31 32 36 public static final ChildPropertyDescriptor EXPRESSION_PROPERTY = 37 new ChildPropertyDescriptor(ExpressionStatement.class, "expression", Expression.class, MANDATORY, CYCLE_RISK); 39 44 private static final List PROPERTY_DESCRIPTORS; 45 46 static { 47 List properyList = new ArrayList (2); 48 createPropertyList(ExpressionStatement.class, properyList); 49 addProperty(EXPRESSION_PROPERTY, properyList); 50 PROPERTY_DESCRIPTORS = reapPropertyList(properyList); 51 } 52 53 64 public static List propertyDescriptors(int apiLevel) { 65 return PROPERTY_DESCRIPTORS; 66 } 67 68 72 private Expression expression = null; 73 74 84 ExpressionStatement(AST ast) { 85 super(ast); 86 } 87 88 91 final List internalStructuralPropertiesForType(int apiLevel) { 92 return propertyDescriptors(apiLevel); 93 } 94 95 98 final ASTNode internalGetSetChildProperty(ChildPropertyDescriptor property, boolean get, ASTNode child) { 99 if (property == EXPRESSION_PROPERTY) { 100 if (get) { 101 return getExpression(); 102 } else { 103 setExpression((Expression) child); 104 return null; 105 } 106 } 107 return super.internalGetSetChildProperty(property, get, child); 109 } 110 111 114 final int getNodeType0() { 115 return EXPRESSION_STATEMENT; 116 } 117 118 121 ASTNode clone0(AST target) { 122 ExpressionStatement result = new ExpressionStatement(target); 123 result.setSourceRange(this.getStartPosition(), this.getLength()); 124 result.copyLeadingComment(this); 125 result.setExpression((Expression) getExpression().clone(target)); 126 return result; 127 } 128 129 132 final boolean subtreeMatch0(ASTMatcher matcher, Object other) { 133 return matcher.match(this, other); 135 } 136 137 140 void accept0(ASTVisitor visitor) { 141 boolean visitChildren = visitor.visit(this); 142 if (visitChildren) { 143 acceptChild(visitor, getExpression()); 144 } 145 visitor.endVisit(this); 146 } 147 148 153 public Expression getExpression() { 154 if (this.expression == null) { 155 synchronized (this) { 157 if (this.expression == null) { 158 preLazyInit(); 159 this.expression = new MethodInvocation(this.ast); 160 postLazyInit(this.expression, EXPRESSION_PROPERTY); 161 } 162 } 163 } 164 return this.expression; 165 } 166 167 178 public void setExpression(Expression expression) { 179 if (expression == null) { 180 throw new IllegalArgumentException (); 181 } 182 ASTNode oldChild = this.expression; 183 preReplaceChild(oldChild, expression, EXPRESSION_PROPERTY); 184 this.expression = expression; 185 postReplaceChild(oldChild, expression, EXPRESSION_PROPERTY); 186 } 187 188 191 int memSize() { 192 return super.memSize() + 1 * 4; 193 } 194 195 198 int treeSize() { 199 return 200 memSize() 201 + (this.expression == null ? 0 : getExpression().treeSize()); 202 } 203 } 204 205 | Popular Tags |