1 11 12 package org.eclipse.jdt.core.dom; 13 14 import java.util.ArrayList ; 15 import java.util.List ; 16 17 57 public class FieldAccess extends Expression { 58 59 63 public static final ChildPropertyDescriptor EXPRESSION_PROPERTY = 64 new ChildPropertyDescriptor(FieldAccess.class, "expression", Expression.class, MANDATORY, CYCLE_RISK); 66 70 public static final ChildPropertyDescriptor NAME_PROPERTY = 71 new ChildPropertyDescriptor(FieldAccess.class, "name", SimpleName.class, MANDATORY, NO_CYCLE_RISK); 73 78 private static final List PROPERTY_DESCRIPTORS; 79 80 static { 81 List properyList = new ArrayList (3); 82 createPropertyList(FieldAccess.class, properyList); 83 addProperty(EXPRESSION_PROPERTY, properyList); 84 addProperty(NAME_PROPERTY, properyList); 85 PROPERTY_DESCRIPTORS = reapPropertyList(properyList); 86 } 87 88 99 public static List propertyDescriptors(int apiLevel) { 100 return PROPERTY_DESCRIPTORS; 101 } 102 103 107 private Expression expression = null; 108 109 113 private SimpleName fieldName = null; 114 115 125 FieldAccess(AST ast) { 126 super(ast); 127 } 128 129 132 final List internalStructuralPropertiesForType(int apiLevel) { 133 return propertyDescriptors(apiLevel); 134 } 135 136 139 final ASTNode internalGetSetChildProperty(ChildPropertyDescriptor property, boolean get, ASTNode child) { 140 if (property == EXPRESSION_PROPERTY) { 141 if (get) { 142 return getExpression(); 143 } else { 144 setExpression((Expression) child); 145 return null; 146 } 147 } 148 if (property == NAME_PROPERTY) { 149 if (get) { 150 return getName(); 151 } else { 152 setName((SimpleName) child); 153 return null; 154 } 155 } 156 return super.internalGetSetChildProperty(property, get, child); 158 } 159 160 163 final int getNodeType0() { 164 return FIELD_ACCESS; 165 } 166 167 170 ASTNode clone0(AST target) { 171 FieldAccess result = new FieldAccess(target); 172 result.setSourceRange(this.getStartPosition(), this.getLength()); 173 result.setExpression((Expression) getExpression().clone(target)); 174 result.setName((SimpleName) getName().clone(target)); 175 return result; 176 } 177 178 181 final boolean subtreeMatch0(ASTMatcher matcher, Object other) { 182 return matcher.match(this, other); 184 } 185 186 189 void accept0(ASTVisitor visitor) { 190 boolean visitChildren = visitor.visit(this); 191 if (visitChildren) { 192 acceptChild(visitor, getExpression()); 194 acceptChild(visitor, getName()); 195 } 196 visitor.endVisit(this); 197 } 198 199 204 public Expression getExpression() { 205 if (this.expression == null) { 206 synchronized (this) { 208 if (this.expression == null) { 209 preLazyInit(); 210 this.expression = new SimpleName(this.ast); 211 postLazyInit(this.expression, EXPRESSION_PROPERTY); 212 } 213 } 214 } 215 return this.expression; 216 } 217 218 229 public void setExpression(Expression expression) { 230 if (expression == null) { 231 throw new IllegalArgumentException (); 232 } 233 ASTNode oldChild = this.expression; 234 preReplaceChild(oldChild, expression, EXPRESSION_PROPERTY); 235 this.expression = expression; 236 postReplaceChild(oldChild, expression, EXPRESSION_PROPERTY); 237 } 238 239 244 public SimpleName getName() { 245 if (this.fieldName == null) { 246 synchronized (this) { 248 if (this.fieldName == null) { 249 preLazyInit(); 250 this.fieldName = new SimpleName(this.ast); 251 postLazyInit(this.fieldName, NAME_PROPERTY); 252 } 253 } 254 } 255 return this.fieldName; 256 } 257 258 268 public void setName(SimpleName fieldName) { 269 if (fieldName == null) { 270 throw new IllegalArgumentException (); 271 } 272 ASTNode oldChild = this.fieldName; 273 preReplaceChild(oldChild, fieldName, NAME_PROPERTY); 274 this.fieldName = fieldName; 275 postReplaceChild(oldChild, fieldName, NAME_PROPERTY); 276 } 277 278 281 int memSize() { 282 return BASE_NODE_SIZE + 2 * 4; 284 } 285 286 298 public IVariableBinding resolveFieldBinding() { 299 return this.ast.getBindingResolver().resolveField(this); 300 } 301 302 305 int treeSize() { 306 return 307 memSize() 308 + (this.expression == null ? 0 : getExpression().treeSize()) 309 + (this.fieldName == null ? 0 : getName().treeSize()); 310 } 311 } 312 313 | Popular Tags |