1 11 12 package org.eclipse.jdt.core.dom; 13 14 import java.util.ArrayList ; 15 import java.util.List ; 16 17 34 public class SuperConstructorInvocation extends Statement { 35 36 40 public static final ChildPropertyDescriptor EXPRESSION_PROPERTY = 41 new ChildPropertyDescriptor(SuperConstructorInvocation.class, "expression", Expression.class, OPTIONAL, CYCLE_RISK); 43 47 public static final ChildListPropertyDescriptor TYPE_ARGUMENTS_PROPERTY = 48 new ChildListPropertyDescriptor(SuperConstructorInvocation.class, "typeArguments", Type.class, NO_CYCLE_RISK); 50 54 public static final ChildListPropertyDescriptor ARGUMENTS_PROPERTY = 55 new ChildListPropertyDescriptor(SuperConstructorInvocation.class, "arguments", Expression.class, CYCLE_RISK); 57 63 private static final List PROPERTY_DESCRIPTORS_2_0; 64 65 71 private static final List PROPERTY_DESCRIPTORS_3_0; 72 73 static { 74 List propertyList = new ArrayList (3); 75 createPropertyList(SuperConstructorInvocation.class, propertyList); 76 addProperty(EXPRESSION_PROPERTY, propertyList); 77 addProperty(ARGUMENTS_PROPERTY, propertyList); 78 PROPERTY_DESCRIPTORS_2_0 = reapPropertyList(propertyList); 79 80 propertyList = new ArrayList (4); 81 createPropertyList(SuperConstructorInvocation.class, propertyList); 82 addProperty(EXPRESSION_PROPERTY, propertyList); 83 addProperty(TYPE_ARGUMENTS_PROPERTY, propertyList); 84 addProperty(ARGUMENTS_PROPERTY, propertyList); 85 PROPERTY_DESCRIPTORS_3_0 = reapPropertyList(propertyList); 86 } 87 88 99 public static List propertyDescriptors(int apiLevel) { 100 if (apiLevel == AST.JLS2_INTERNAL) { 101 return PROPERTY_DESCRIPTORS_2_0; 102 } else { 103 return PROPERTY_DESCRIPTORS_3_0; 104 } 105 } 106 107 110 private Expression optionalExpression = null; 111 112 118 private ASTNode.NodeList typeArguments = null; 119 120 124 private ASTNode.NodeList arguments = 125 new ASTNode.NodeList(ARGUMENTS_PROPERTY); 126 127 134 SuperConstructorInvocation(AST ast) { 135 super(ast); 136 if (ast.apiLevel >= AST.JLS3) { 137 this.typeArguments = new ASTNode.NodeList(TYPE_ARGUMENTS_PROPERTY); 138 } 139 } 140 141 144 final List internalStructuralPropertiesForType(int apiLevel) { 145 return propertyDescriptors(apiLevel); 146 } 147 148 151 final ASTNode internalGetSetChildProperty(ChildPropertyDescriptor property, boolean get, ASTNode child) { 152 if (property == EXPRESSION_PROPERTY) { 153 if (get) { 154 return getExpression(); 155 } else { 156 setExpression((Expression) child); 157 return null; 158 } 159 } 160 return super.internalGetSetChildProperty(property, get, child); 162 } 163 164 167 final List internalGetChildListProperty(ChildListPropertyDescriptor property) { 168 if (property == ARGUMENTS_PROPERTY) { 169 return arguments(); 170 } 171 if (property == TYPE_ARGUMENTS_PROPERTY) { 172 return typeArguments(); 173 } 174 return super.internalGetChildListProperty(property); 176 } 177 178 181 final int getNodeType0() { 182 return SUPER_CONSTRUCTOR_INVOCATION; 183 } 184 185 188 ASTNode clone0(AST target) { 189 SuperConstructorInvocation result = new SuperConstructorInvocation(target); 190 result.setSourceRange(this.getStartPosition(), this.getLength()); 191 result.copyLeadingComment(this); 192 result.setExpression( 193 (Expression) ASTNode.copySubtree(target, getExpression())); 194 if (this.ast.apiLevel >= AST.JLS3) { 195 result.typeArguments().addAll(ASTNode.copySubtrees(target, typeArguments())); 196 } 197 result.arguments().addAll(ASTNode.copySubtrees(target, arguments())); 198 return result; 199 } 200 201 204 final boolean subtreeMatch0(ASTMatcher matcher, Object other) { 205 return matcher.match(this, other); 207 } 208 209 212 void accept0(ASTVisitor visitor) { 213 boolean visitChildren = visitor.visit(this); 214 if (visitChildren) { 215 acceptChild(visitor, getExpression()); 217 if (this.ast.apiLevel >= AST.JLS3) { 218 acceptChildren(visitor, this.typeArguments); 219 } 220 acceptChildren(visitor, this.arguments); 221 } 222 visitor.endVisit(this); 223 } 224 225 231 public Expression getExpression() { 232 return this.optionalExpression; 233 } 234 235 248 public void setExpression(Expression expression) { 249 ASTNode oldChild = this.optionalExpression; 250 preReplaceChild(oldChild, expression, EXPRESSION_PROPERTY); 251 this.optionalExpression = expression; 252 postReplaceChild(oldChild, expression, EXPRESSION_PROPERTY); 253 } 254 255 265 public List typeArguments() { 266 if (this.typeArguments == null) { 268 unsupportedIn2(); 269 } 270 return this.typeArguments; 271 } 272 273 280 public List arguments() { 281 return this.arguments; 282 } 283 284 295 public IMethodBinding resolveConstructorBinding() { 296 return this.ast.getBindingResolver().resolveConstructor(this); 297 } 298 299 302 int memSize() { 303 return BASE_NODE_SIZE + 3 * 4; 305 } 306 307 310 int treeSize() { 311 return memSize() 312 + (this.optionalExpression == null ? 0 : getExpression().treeSize()) 313 + (this.typeArguments == null ? 0 : this.typeArguments.listSize()) 314 + (this.arguments == null ? 0 : this.arguments.listSize()); 315 } 316 } 317 | Popular Tags |