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 ConstructorInvocation extends Statement { 34 35 39 public static final ChildListPropertyDescriptor TYPE_ARGUMENTS_PROPERTY = 40 new ChildListPropertyDescriptor(ConstructorInvocation.class, "typeArguments", Type.class, NO_CYCLE_RISK); 42 46 public static final ChildListPropertyDescriptor ARGUMENTS_PROPERTY = 47 new ChildListPropertyDescriptor(ConstructorInvocation.class, "arguments", Expression.class, CYCLE_RISK); 49 55 private static final List PROPERTY_DESCRIPTORS_2_0; 56 57 63 private static final List PROPERTY_DESCRIPTORS_3_0; 64 65 static { 66 List properyList = new ArrayList (2); 67 createPropertyList(ConstructorInvocation.class, properyList); 68 addProperty(ARGUMENTS_PROPERTY, properyList); 69 PROPERTY_DESCRIPTORS_2_0 = reapPropertyList(properyList); 70 71 properyList = new ArrayList (3); 72 createPropertyList(ConstructorInvocation.class, properyList); 73 addProperty(TYPE_ARGUMENTS_PROPERTY, properyList); 74 addProperty(ARGUMENTS_PROPERTY, properyList); 75 PROPERTY_DESCRIPTORS_3_0 = reapPropertyList(properyList); 76 } 77 78 89 public static List propertyDescriptors(int apiLevel) { 90 if (apiLevel == AST.JLS2_INTERNAL) { 91 return PROPERTY_DESCRIPTORS_2_0; 92 } else { 93 return PROPERTY_DESCRIPTORS_3_0; 94 } 95 } 96 97 103 private ASTNode.NodeList typeArguments = null; 104 105 109 private ASTNode.NodeList arguments = 110 new ASTNode.NodeList(ARGUMENTS_PROPERTY); 111 112 118 ConstructorInvocation(AST ast) { 119 super(ast); 120 if (ast.apiLevel >= AST.JLS3) { 121 this.typeArguments = new ASTNode.NodeList(TYPE_ARGUMENTS_PROPERTY); 122 } 123 } 124 125 128 final List internalStructuralPropertiesForType(int apiLevel) { 129 return propertyDescriptors(apiLevel); 130 } 131 132 135 final List internalGetChildListProperty(ChildListPropertyDescriptor property) { 136 if (property == ARGUMENTS_PROPERTY) { 137 return arguments(); 138 } 139 if (property == TYPE_ARGUMENTS_PROPERTY) { 140 return typeArguments(); 141 } 142 return super.internalGetChildListProperty(property); 144 } 145 146 149 final int getNodeType0() { 150 return CONSTRUCTOR_INVOCATION; 151 } 152 153 156 ASTNode clone0(AST target) { 157 ConstructorInvocation result = new ConstructorInvocation(target); 158 result.setSourceRange(this.getStartPosition(), this.getLength()); 159 result.copyLeadingComment(this); 160 if (this.ast.apiLevel >= AST.JLS3) { 161 result.typeArguments().addAll(ASTNode.copySubtrees(target, typeArguments())); 162 } 163 result.arguments().addAll(ASTNode.copySubtrees(target, arguments())); 164 return result; 165 } 166 167 170 final boolean subtreeMatch0(ASTMatcher matcher, Object other) { 171 return matcher.match(this, other); 173 } 174 175 178 void accept0(ASTVisitor visitor) { 179 boolean visitChildren = visitor.visit(this); 180 if (visitChildren) { 181 if (this.ast.apiLevel >= AST.JLS3) { 182 acceptChildren(visitor, this.typeArguments); 183 } 184 acceptChildren(visitor, this.arguments); 185 } 186 visitor.endVisit(this); 187 } 188 189 199 public List typeArguments() { 200 if (this.typeArguments == null) { 202 unsupportedIn2(); 203 } 204 return this.typeArguments; 205 } 206 207 214 public List arguments() { 215 return this.arguments; 216 } 217 218 229 public IMethodBinding resolveConstructorBinding() { 230 return this.ast.getBindingResolver().resolveConstructor(this); 231 } 232 233 236 int memSize() { 237 return BASE_NODE_SIZE + 2 * 4; 239 } 240 241 244 int treeSize() { 245 return 246 memSize() 247 + (this.typeArguments == null ? 0 : this.typeArguments.listSize()) 248 + (this.arguments == null ? 0 : this.arguments.listSize()); 249 } 250 } 251 252 | Popular Tags |