1 11 12 package org.eclipse.jdt.core.dom; 13 14 import java.util.ArrayList ; 15 import java.util.List ; 16 17 35 public class SuperMethodInvocation extends Expression { 36 37 41 public static final ChildPropertyDescriptor QUALIFIER_PROPERTY = 42 new ChildPropertyDescriptor(SuperMethodInvocation.class, "qualifier", Name.class, OPTIONAL, NO_CYCLE_RISK); 44 48 public static final ChildListPropertyDescriptor TYPE_ARGUMENTS_PROPERTY = 49 new ChildListPropertyDescriptor(SuperMethodInvocation.class, "typeArguments", Type.class, NO_CYCLE_RISK); 51 55 public static final ChildPropertyDescriptor NAME_PROPERTY = 56 new ChildPropertyDescriptor(SuperMethodInvocation.class, "name", SimpleName.class, MANDATORY, NO_CYCLE_RISK); 58 62 public static final ChildListPropertyDescriptor ARGUMENTS_PROPERTY = 63 new ChildListPropertyDescriptor(SuperMethodInvocation.class, "arguments", Expression.class, CYCLE_RISK); 65 71 private static final List PROPERTY_DESCRIPTORS_2_0; 72 73 79 private static final List PROPERTY_DESCRIPTORS_3_0; 80 81 static { 82 List propertyList = new ArrayList (4); 83 createPropertyList(SuperMethodInvocation.class, propertyList); 84 addProperty(QUALIFIER_PROPERTY, propertyList); 85 addProperty(NAME_PROPERTY, propertyList); 86 addProperty(ARGUMENTS_PROPERTY, propertyList); 87 PROPERTY_DESCRIPTORS_2_0 = reapPropertyList(propertyList); 88 89 propertyList = new ArrayList (5); 90 createPropertyList(SuperMethodInvocation.class, propertyList); 91 addProperty(QUALIFIER_PROPERTY, propertyList); 92 addProperty(TYPE_ARGUMENTS_PROPERTY, propertyList); 93 addProperty(NAME_PROPERTY, propertyList); 94 addProperty(ARGUMENTS_PROPERTY, propertyList); 95 PROPERTY_DESCRIPTORS_3_0 = reapPropertyList(propertyList); 96 } 97 98 109 public static List propertyDescriptors(int apiLevel) { 110 if (apiLevel == AST.JLS2_INTERNAL) { 111 return PROPERTY_DESCRIPTORS_2_0; 112 } else { 113 return PROPERTY_DESCRIPTORS_3_0; 114 } 115 } 116 117 120 private Name optionalQualifier = null; 121 122 128 private ASTNode.NodeList typeArguments = null; 129 130 134 private SimpleName methodName = null; 135 136 140 private ASTNode.NodeList arguments = 141 new ASTNode.NodeList(ARGUMENTS_PROPERTY); 142 143 150 SuperMethodInvocation(AST ast) { 151 super(ast); 152 if (ast.apiLevel >= AST.JLS3) { 153 this.typeArguments = new ASTNode.NodeList(TYPE_ARGUMENTS_PROPERTY); 154 } 155 } 156 157 160 final List internalStructuralPropertiesForType(int apiLevel) { 161 return propertyDescriptors(apiLevel); 162 } 163 164 167 final ASTNode internalGetSetChildProperty(ChildPropertyDescriptor property, boolean get, ASTNode child) { 168 if (property == QUALIFIER_PROPERTY) { 169 if (get) { 170 return getQualifier(); 171 } else { 172 setQualifier((Name) child); 173 return null; 174 } 175 } 176 if (property == NAME_PROPERTY) { 177 if (get) { 178 return getName(); 179 } else { 180 setName((SimpleName) child); 181 return null; 182 } 183 } 184 return super.internalGetSetChildProperty(property, get, child); 186 } 187 188 191 final List internalGetChildListProperty(ChildListPropertyDescriptor property) { 192 if (property == ARGUMENTS_PROPERTY) { 193 return arguments(); 194 } 195 if (property == TYPE_ARGUMENTS_PROPERTY) { 196 return typeArguments(); 197 } 198 return super.internalGetChildListProperty(property); 200 } 201 202 205 final int getNodeType0() { 206 return SUPER_METHOD_INVOCATION; 207 } 208 209 212 ASTNode clone0(AST target) { 213 SuperMethodInvocation result = new SuperMethodInvocation(target); 214 result.setSourceRange(this.getStartPosition(), this.getLength()); 215 result.setName((SimpleName) getName().clone(target)); 216 result.setQualifier((Name) ASTNode.copySubtree(target, getQualifier())); 217 if (this.ast.apiLevel >= AST.JLS3) { 218 result.typeArguments().addAll(ASTNode.copySubtrees(target, typeArguments())); 219 } 220 result.arguments().addAll(ASTNode.copySubtrees(target, arguments())); 221 return result; 222 } 223 224 227 final boolean subtreeMatch0(ASTMatcher matcher, Object other) { 228 return matcher.match(this, other); 230 } 231 232 235 void accept0(ASTVisitor visitor) { 236 boolean visitChildren = visitor.visit(this); 237 if (visitChildren) { 238 acceptChild(visitor, getQualifier()); 240 if (this.ast.apiLevel >= AST.JLS3) { 241 acceptChildren(visitor, this.typeArguments); 242 } 243 acceptChild(visitor, getName()); 244 acceptChildren(visitor, this.arguments); 245 } 246 visitor.endVisit(this); 247 } 248 249 255 public Name getQualifier() { 256 return this.optionalQualifier; 257 } 258 259 270 public void setQualifier(Name name) { 271 ASTNode oldChild = this.optionalQualifier; 272 preReplaceChild(oldChild, name, QUALIFIER_PROPERTY); 273 this.optionalQualifier = name; 274 postReplaceChild(oldChild, name, QUALIFIER_PROPERTY); 275 } 276 277 287 public List typeArguments() { 288 if (this.typeArguments == null) { 290 unsupportedIn2(); 291 } 292 return this.typeArguments; 293 } 294 295 300 public SimpleName getName() { 301 if (this.methodName == null) { 302 synchronized (this) { 304 if (this.methodName == null) { 305 preLazyInit(); 306 this.methodName = new SimpleName(this.ast); 307 postLazyInit(this.methodName, NAME_PROPERTY); 308 } 309 } 310 } 311 return this.methodName; 312 } 313 314 325 public void setName(SimpleName name) { 326 if (name == null) { 327 throw new IllegalArgumentException (); 328 } 329 ASTNode oldChild = this.methodName; 330 preReplaceChild(oldChild, name, NAME_PROPERTY); 331 this.methodName = name; 332 postReplaceChild(oldChild, name, NAME_PROPERTY); 333 } 334 335 342 public List arguments() { 343 return this.arguments; 344 } 345 346 358 public IMethodBinding resolveMethodBinding() { 359 return this.ast.getBindingResolver().resolveMethod(this); 360 } 361 362 365 int memSize() { 366 return BASE_NODE_SIZE + 4 * 4; 368 } 369 370 373 int treeSize() { 374 return 375 memSize() 376 + (this.optionalQualifier == null ? 0 : getQualifier().treeSize()) 377 + (this.typeArguments == null ? 0 : this.typeArguments.listSize()) 378 + (this.methodName == null ? 0 : getName().treeSize()) 379 + (this.arguments == null ? 0 : this.arguments.listSize()); 380 } 381 } 382 383 | Popular Tags |