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 ParameterizedType extends Type { 31 34 int index; 35 36 39 public static final ChildPropertyDescriptor TYPE_PROPERTY = 40 new ChildPropertyDescriptor(ParameterizedType.class, "type", Type.class, MANDATORY, CYCLE_RISK); 42 45 public static final ChildListPropertyDescriptor TYPE_ARGUMENTS_PROPERTY = 46 new ChildListPropertyDescriptor(ParameterizedType.class, "typeArguments", Type.class, CYCLE_RISK); 48 53 private static final List PROPERTY_DESCRIPTORS; 54 55 static { 56 List propertyList = new ArrayList (3); 57 createPropertyList(ParameterizedType.class, propertyList); 58 addProperty(TYPE_PROPERTY, propertyList); 59 addProperty(TYPE_ARGUMENTS_PROPERTY, propertyList); 60 PROPERTY_DESCRIPTORS = reapPropertyList(propertyList); 61 } 62 63 73 public static List propertyDescriptors(int apiLevel) { 74 return PROPERTY_DESCRIPTORS; 75 } 76 77 81 private Type type = null; 82 83 87 private ASTNode.NodeList typeArguments = 88 new ASTNode.NodeList(TYPE_ARGUMENTS_PROPERTY); 89 90 100 ParameterizedType(AST ast) { 101 super(ast); 102 unsupportedIn2(); 103 } 104 105 108 final List internalStructuralPropertiesForType(int apiLevel) { 109 return propertyDescriptors(apiLevel); 110 } 111 112 115 final ASTNode internalGetSetChildProperty(ChildPropertyDescriptor property, boolean get, ASTNode child) { 116 if (property == TYPE_PROPERTY) { 117 if (get) { 118 return getType(); 119 } else { 120 setType((Type) child); 121 return null; 122 } 123 } 124 return super.internalGetSetChildProperty(property, get, child); 126 } 127 128 131 final List internalGetChildListProperty(ChildListPropertyDescriptor property) { 132 if (property == TYPE_ARGUMENTS_PROPERTY) { 133 return typeArguments(); 134 } 135 return super.internalGetChildListProperty(property); 137 } 138 139 142 final int getNodeType0() { 143 return PARAMETERIZED_TYPE; 144 } 145 146 149 ASTNode clone0(AST target) { 150 ParameterizedType result = new ParameterizedType(target); 151 result.setSourceRange(this.getStartPosition(), this.getLength()); 152 result.setType((Type) ((ASTNode) getType()).clone(target)); 153 result.typeArguments().addAll( 154 ASTNode.copySubtrees(target, typeArguments())); 155 return result; 156 } 157 158 161 final boolean subtreeMatch0(ASTMatcher matcher, Object other) { 162 return matcher.match(this, other); 164 } 165 166 169 void accept0(ASTVisitor visitor) { 170 boolean visitChildren = visitor.visit(this); 171 if (visitChildren) { 172 acceptChild(visitor, getType()); 174 acceptChildren(visitor, this.typeArguments); 175 } 176 visitor.endVisit(this); 177 } 178 179 184 public Type getType() { 185 if (this.type == null) { 186 synchronized (this) { 188 if (this.type == null) { 189 preLazyInit(); 190 this.type = new SimpleType(this.ast); 191 postLazyInit(this.type, TYPE_PROPERTY); 192 } 193 } 194 } 195 return this.type; 196 } 197 198 208 public void setType(Type type) { 209 if (type == null) { 210 throw new IllegalArgumentException (); 211 } 212 ASTNode oldChild = this.type; 213 preReplaceChild(oldChild, type, TYPE_PROPERTY); 214 this.type = type; 215 postReplaceChild(oldChild, type, TYPE_PROPERTY); 216 } 217 218 226 public List typeArguments() { 227 return this.typeArguments; 228 } 229 230 233 int memSize() { 234 return BASE_NODE_SIZE + 3 * 4; 236 } 237 238 241 int treeSize() { 242 return 243 memSize() 244 + (this.type == null ? 0 : getType().treeSize()) 245 + this.typeArguments.listSize(); 246 } 247 } 248 249 | Popular Tags |