1 11 12 package org.eclipse.jdt.core.dom; 13 14 import java.util.ArrayList ; 15 import java.util.List ; 16 17 26 public class TypeParameter extends ASTNode { 27 28 31 public static final ChildPropertyDescriptor NAME_PROPERTY = 32 new ChildPropertyDescriptor(TypeParameter.class, "name", SimpleName.class, MANDATORY, NO_CYCLE_RISK); 34 37 public static final ChildListPropertyDescriptor TYPE_BOUNDS_PROPERTY = 38 new ChildListPropertyDescriptor(TypeParameter.class, "typeBounds", Type.class, NO_CYCLE_RISK); 40 45 private static final List PROPERTY_DESCRIPTORS; 46 47 static { 48 List propertyList = new ArrayList (3); 49 createPropertyList(TypeParameter.class, propertyList); 50 addProperty(NAME_PROPERTY, propertyList); 51 addProperty(TYPE_BOUNDS_PROPERTY, propertyList); 52 PROPERTY_DESCRIPTORS = reapPropertyList(propertyList); 53 } 54 55 65 public static List propertyDescriptors(int apiLevel) { 66 return PROPERTY_DESCRIPTORS; 67 } 68 69 73 private SimpleName typeVariableName = null; 74 75 79 private ASTNode.NodeList typeBounds = 80 new ASTNode.NodeList(TYPE_BOUNDS_PROPERTY); 81 82 92 TypeParameter(AST ast) { 93 super(ast); 94 unsupportedIn2(); 95 } 96 97 100 final List internalStructuralPropertiesForType(int apiLevel) { 101 return propertyDescriptors(apiLevel); 102 } 103 104 107 final ASTNode internalGetSetChildProperty(ChildPropertyDescriptor property, boolean get, ASTNode child) { 108 if (property == NAME_PROPERTY) { 109 if (get) { 110 return getName(); 111 } else { 112 setName((SimpleName) child); 113 return null; 114 } 115 } 116 return super.internalGetSetChildProperty(property, get, child); 118 } 119 120 123 final List internalGetChildListProperty(ChildListPropertyDescriptor property) { 124 if (property == TYPE_BOUNDS_PROPERTY) { 125 return typeBounds(); 126 } 127 return super.internalGetChildListProperty(property); 129 } 130 131 134 final int getNodeType0() { 135 return TYPE_PARAMETER; 136 } 137 138 141 ASTNode clone0(AST target) { 142 TypeParameter result = new TypeParameter(target); 143 result.setSourceRange(this.getStartPosition(), this.getLength()); 144 result.setName((SimpleName) ((ASTNode) getName()).clone(target)); 145 result.typeBounds().addAll( 146 ASTNode.copySubtrees(target, typeBounds())); 147 return result; 148 } 149 150 153 final boolean subtreeMatch0(ASTMatcher matcher, Object other) { 154 return matcher.match(this, other); 156 } 157 158 161 void accept0(ASTVisitor visitor) { 162 boolean visitChildren = visitor.visit(this); 163 if (visitChildren) { 164 acceptChild(visitor, getName()); 166 acceptChildren(visitor, this.typeBounds); 167 } 168 visitor.endVisit(this); 169 } 170 171 176 public SimpleName getName() { 177 if (this.typeVariableName == null) { 178 synchronized (this) { 180 if (this.typeVariableName == null) { 181 preLazyInit(); 182 this.typeVariableName = new SimpleName(this.ast); 183 postLazyInit(this.typeVariableName, NAME_PROPERTY); 184 } 185 } 186 } 187 return this.typeVariableName; 188 } 189 190 200 public final ITypeBinding resolveBinding() { 201 return this.ast.getBindingResolver().resolveTypeParameter(this); 202 } 203 204 215 public void setName(SimpleName typeName) { 216 if (typeName == null) { 217 throw new IllegalArgumentException (); 218 } 219 ASTNode oldChild = this.typeVariableName; 220 preReplaceChild(oldChild, typeName, NAME_PROPERTY); 221 this.typeVariableName = typeName; 222 postReplaceChild(oldChild, typeName, NAME_PROPERTY); 223 } 224 225 235 public List typeBounds() { 236 return this.typeBounds; 237 } 238 239 242 int memSize() { 243 return BASE_NODE_SIZE + 2 * 4; 245 } 246 247 250 int treeSize() { 251 return 252 memSize() 253 + (this.typeVariableName == null ? 0 : getName().treeSize()) 254 + this.typeBounds.listSize(); 255 } 256 } 257 258 | Popular Tags |