1 11 12 package org.eclipse.jdt.core.dom; 13 14 import java.util.ArrayList ; 15 import java.util.List ; 16 17 33 public class SuperFieldAccess extends Expression { 34 35 39 public static final ChildPropertyDescriptor QUALIFIER_PROPERTY = 40 new ChildPropertyDescriptor(SuperFieldAccess.class, "qualifier", Name.class, OPTIONAL, NO_CYCLE_RISK); 42 46 public static final ChildPropertyDescriptor NAME_PROPERTY = 47 new ChildPropertyDescriptor(SuperFieldAccess.class, "name", SimpleName.class, MANDATORY, NO_CYCLE_RISK); 49 54 private static final List PROPERTY_DESCRIPTORS; 55 56 static { 57 List propertyList = new ArrayList (3); 58 createPropertyList(SuperFieldAccess.class, propertyList); 59 addProperty(QUALIFIER_PROPERTY, propertyList); 60 addProperty(NAME_PROPERTY, propertyList); 61 PROPERTY_DESCRIPTORS = reapPropertyList(propertyList); 62 } 63 64 74 public static List propertyDescriptors(int apiLevel) { 75 return PROPERTY_DESCRIPTORS; 76 } 77 78 81 private Name optionalQualifier = null; 82 83 87 private SimpleName fieldName = null; 88 89 99 SuperFieldAccess(AST ast) { 100 super(ast); 101 } 102 103 106 final List internalStructuralPropertiesForType(int apiLevel) { 107 return propertyDescriptors(apiLevel); 108 } 109 110 113 final ASTNode internalGetSetChildProperty(ChildPropertyDescriptor property, boolean get, ASTNode child) { 114 if (property == QUALIFIER_PROPERTY) { 115 if (get) { 116 return getQualifier(); 117 } else { 118 setQualifier((Name) child); 119 return null; 120 } 121 } 122 if (property == NAME_PROPERTY) { 123 if (get) { 124 return getName(); 125 } else { 126 setName((SimpleName) child); 127 return null; 128 } 129 } 130 return super.internalGetSetChildProperty(property, get, child); 132 } 133 134 137 final int getNodeType0() { 138 return SUPER_FIELD_ACCESS; 139 } 140 141 144 ASTNode clone0(AST target) { 145 SuperFieldAccess result = new SuperFieldAccess(target); 146 result.setSourceRange(this.getStartPosition(), this.getLength()); 147 result.setName((SimpleName) ASTNode.copySubtree(target, getName())); 148 result.setQualifier((Name) ASTNode.copySubtree(target, getQualifier())); 149 return result; 150 } 151 152 155 final boolean subtreeMatch0(ASTMatcher matcher, Object other) { 156 return matcher.match(this, other); 158 } 159 160 163 void accept0(ASTVisitor visitor) { 164 boolean visitChildren = visitor.visit(this); 165 if (visitChildren) { 166 acceptChild(visitor, getQualifier()); 168 acceptChild(visitor, getName()); 169 } 170 visitor.endVisit(this); 171 } 172 173 179 public Name getQualifier() { 180 return this.optionalQualifier; 181 } 182 183 194 public void setQualifier(Name name) { 195 ASTNode oldChild = this.optionalQualifier; 196 preReplaceChild(oldChild, name, QUALIFIER_PROPERTY); 197 this.optionalQualifier = name; 198 postReplaceChild(oldChild, name, QUALIFIER_PROPERTY); 199 } 200 201 207 public SimpleName getName() { 208 if (this.fieldName == null) { 209 synchronized (this) { 211 if (this.fieldName == null) { 212 preLazyInit(); 213 this.fieldName = new SimpleName(this.ast); 214 postLazyInit(this.fieldName, NAME_PROPERTY); 215 } 216 } 217 } 218 return this.fieldName; 219 } 220 221 233 public IVariableBinding resolveFieldBinding() { 234 return this.ast.getBindingResolver().resolveField(this); 235 } 236 237 248 public void setName(SimpleName fieldName) { 249 if (fieldName == null) { 250 throw new IllegalArgumentException (); 251 } 252 ASTNode oldChild = this.fieldName; 253 preReplaceChild(oldChild, fieldName, NAME_PROPERTY); 254 this.fieldName = fieldName; 255 postReplaceChild(oldChild, fieldName, NAME_PROPERTY); 256 } 257 258 261 int memSize() { 262 return BASE_NODE_SIZE + 2 * 4; 264 } 265 266 269 int treeSize() { 270 return 271 memSize() 272 + (this.optionalQualifier == null ? 0 : getQualifier().treeSize()) 273 + (this.fieldName == null ? 0 : getName().treeSize()); 274 } 275 } 276 277 | Popular Tags |