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 MemberRef extends ASTNode implements IDocElement { 31 32 36 public static final ChildPropertyDescriptor QUALIFIER_PROPERTY = 37 new ChildPropertyDescriptor(MemberRef.class, "qualifier", Name.class, OPTIONAL, NO_CYCLE_RISK); 39 43 public static final ChildPropertyDescriptor NAME_PROPERTY = 44 new ChildPropertyDescriptor(MemberRef.class, "name", SimpleName.class, MANDATORY, NO_CYCLE_RISK); 46 51 private static final List PROPERTY_DESCRIPTORS; 52 53 static { 54 List propertyList = new ArrayList (3); 55 createPropertyList(MemberRef.class, propertyList); 56 addProperty(QUALIFIER_PROPERTY, propertyList); 57 addProperty(NAME_PROPERTY, propertyList); 58 PROPERTY_DESCRIPTORS = reapPropertyList(propertyList); 59 } 60 61 70 public static List propertyDescriptors(int apiLevel) { 71 return PROPERTY_DESCRIPTORS; 72 } 73 74 77 private Name optionalQualifier = null; 78 79 83 private SimpleName memberName = null; 84 85 97 MemberRef(AST ast) { 98 super(ast); 99 } 100 101 104 final List internalStructuralPropertiesForType(int apiLevel) { 105 return propertyDescriptors(apiLevel); 106 } 107 108 111 final ASTNode internalGetSetChildProperty(ChildPropertyDescriptor property, boolean get, ASTNode child) { 112 if (property == QUALIFIER_PROPERTY) { 113 if (get) { 114 return getQualifier(); 115 } else { 116 setQualifier((Name) child); 117 return null; 118 } 119 } 120 if (property == NAME_PROPERTY) { 121 if (get) { 122 return getName(); 123 } else { 124 setName((SimpleName) child); 125 return null; 126 } 127 } 128 return super.internalGetSetChildProperty(property, get, child); 130 } 131 132 135 final int getNodeType0() { 136 return MEMBER_REF; 137 } 138 139 142 ASTNode clone0(AST target) { 143 MemberRef result = new MemberRef(target); 144 result.setSourceRange(this.getStartPosition(), this.getLength()); 145 result.setQualifier((Name) ASTNode.copySubtree(target, getQualifier())); 146 result.setName((SimpleName) ASTNode.copySubtree(target, getName())); 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, getQualifier()); 166 acceptChild(visitor, getName()); 167 } 168 visitor.endVisit(this); 169 } 170 171 177 public Name getQualifier() { 178 return this.optionalQualifier; 179 } 180 181 192 public void setQualifier(Name name) { 193 ASTNode oldChild = this.optionalQualifier; 194 preReplaceChild(oldChild, name, QUALIFIER_PROPERTY); 195 this.optionalQualifier = name; 196 postReplaceChild(oldChild, name, QUALIFIER_PROPERTY); 197 } 198 199 204 public SimpleName getName() { 205 if (this.memberName == null) { 206 synchronized (this) { 208 if (this.memberName == null) { 209 preLazyInit(); 210 this.memberName = new SimpleName(this.ast); 211 postLazyInit(this.memberName, NAME_PROPERTY); 212 } 213 } 214 } 215 return this.memberName; 216 } 217 218 229 public void setName(SimpleName name) { 230 if (name == null) { 231 throw new IllegalArgumentException (); 232 } 233 ASTNode oldChild = this.memberName; 234 preReplaceChild(oldChild, name, NAME_PROPERTY); 235 this.memberName = name; 236 postReplaceChild(oldChild, name, NAME_PROPERTY); 237 } 238 239 250 public final IBinding resolveBinding() { 251 return this.ast.getBindingResolver().resolveReference(this); 252 } 253 254 257 int memSize() { 258 return BASE_NODE_SIZE + 2 * 4; 259 } 260 261 264 int treeSize() { 265 return 266 memSize() 267 + (this.optionalQualifier == null ? 0 : getQualifier().treeSize()) 268 + (this.memberName == null ? 0 : getName().treeSize()); 269 } 270 } 271 272
| Popular Tags
|