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 MethodRef extends ASTNode implements IDocElement { 31 32 36 public static final ChildPropertyDescriptor QUALIFIER_PROPERTY = 37 new ChildPropertyDescriptor(MethodRef.class, "qualifier", Name.class, OPTIONAL, NO_CYCLE_RISK); 39 43 public static final ChildPropertyDescriptor NAME_PROPERTY = 44 new ChildPropertyDescriptor(MethodRef.class, "name", SimpleName.class, MANDATORY, NO_CYCLE_RISK); 46 50 public static final ChildListPropertyDescriptor PARAMETERS_PROPERTY = 51 new ChildListPropertyDescriptor(MethodRef.class, "parameters", MethodRefParameter.class, NO_CYCLE_RISK); 53 58 private static final List PROPERTY_DESCRIPTORS; 59 60 static { 61 List properyList = new ArrayList (4); 62 createPropertyList(MethodRef.class, properyList); 63 addProperty(QUALIFIER_PROPERTY, properyList); 64 addProperty(NAME_PROPERTY, properyList); 65 addProperty(PARAMETERS_PROPERTY, properyList); 66 PROPERTY_DESCRIPTORS = reapPropertyList(properyList); 67 } 68 69 78 public static List propertyDescriptors(int apiLevel) { 79 return PROPERTY_DESCRIPTORS; 80 } 81 82 85 private Name optionalQualifier = null; 86 87 91 private SimpleName methodName = null; 92 93 98 private ASTNode.NodeList parameters = 99 new ASTNode.NodeList(PARAMETERS_PROPERTY); 100 101 102 115 MethodRef(AST ast) { 116 super(ast); 117 } 118 119 122 final List internalStructuralPropertiesForType(int apiLevel) { 123 return propertyDescriptors(apiLevel); 124 } 125 126 129 final ASTNode internalGetSetChildProperty(ChildPropertyDescriptor property, boolean get, ASTNode child) { 130 if (property == QUALIFIER_PROPERTY) { 131 if (get) { 132 return getQualifier(); 133 } else { 134 setQualifier((Name) child); 135 return null; 136 } 137 } 138 if (property == NAME_PROPERTY) { 139 if (get) { 140 return getName(); 141 } else { 142 setName((SimpleName) child); 143 return null; 144 } 145 } 146 return super.internalGetSetChildProperty(property, get, child); 148 } 149 150 153 final List internalGetChildListProperty(ChildListPropertyDescriptor property) { 154 if (property == PARAMETERS_PROPERTY) { 155 return parameters(); 156 } 157 return super.internalGetChildListProperty(property); 159 } 160 161 164 final int getNodeType0() { 165 return METHOD_REF; 166 } 167 168 171 ASTNode clone0(AST target) { 172 MethodRef result = new MethodRef(target); 173 result.setSourceRange(this.getStartPosition(), this.getLength()); 174 result.setQualifier((Name) ASTNode.copySubtree(target, getQualifier())); 175 result.setName((SimpleName) ASTNode.copySubtree(target, getName())); 176 result.parameters().addAll( 177 ASTNode.copySubtrees(target, parameters())); 178 return result; 179 } 180 181 184 final boolean subtreeMatch0(ASTMatcher matcher, Object other) { 185 return matcher.match(this, other); 187 } 188 189 192 void accept0(ASTVisitor visitor) { 193 boolean visitChildren = visitor.visit(this); 194 if (visitChildren) { 195 acceptChild(visitor, getQualifier()); 197 acceptChild(visitor, getName()); 198 acceptChildren(visitor, this.parameters); 199 } 200 visitor.endVisit(this); 201 } 202 203 209 public Name getQualifier() { 210 return this.optionalQualifier; 211 } 212 213 224 public void setQualifier(Name name) { 225 ASTNode oldChild = this.optionalQualifier; 226 preReplaceChild(oldChild, name, QUALIFIER_PROPERTY); 227 this.optionalQualifier = name; 228 postReplaceChild(oldChild, name, QUALIFIER_PROPERTY); 229 } 230 231 236 public SimpleName getName() { 237 if (this.methodName == null) { 238 synchronized (this) { 240 if (this.methodName == null) { 241 preLazyInit(); 242 this.methodName = new SimpleName(this.ast); 243 postLazyInit(this.methodName, NAME_PROPERTY); 244 } 245 } 246 } 247 return this.methodName; 248 } 249 250 262 public void setName(SimpleName name) { 263 if (name == null) { 264 throw new IllegalArgumentException (); 265 } 266 ASTNode oldChild = this.methodName; 267 preReplaceChild(oldChild, name, NAME_PROPERTY); 268 this.methodName = name; 269 postReplaceChild(oldChild, name, NAME_PROPERTY); 270 } 271 272 279 public List parameters() { 280 return this.parameters; 281 } 282 283 294 public final IBinding resolveBinding() { 295 return this.ast.getBindingResolver().resolveReference(this); 296 } 297 298 301 int memSize() { 302 return BASE_NODE_SIZE + 3 * 4; 303 } 304 305 308 int treeSize() { 309 return 310 memSize() 311 + (this.optionalQualifier == null ? 0 : getQualifier().treeSize()) 312 + (this.methodName == null ? 0 : getName().treeSize()) 313 + this.parameters.listSize(); 314 } 315 } 316 317 | Popular Tags |