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 SimpleType extends Type { 27 28 32 public static final ChildPropertyDescriptor NAME_PROPERTY = 33 new ChildPropertyDescriptor(SimpleType.class, "name", Name.class, MANDATORY, NO_CYCLE_RISK); 35 40 private static final List PROPERTY_DESCRIPTORS; 41 42 static { 43 List propertyList = new ArrayList (2); 44 createPropertyList(SimpleType.class, propertyList); 45 addProperty(NAME_PROPERTY, propertyList); 46 PROPERTY_DESCRIPTORS = reapPropertyList(propertyList); 47 } 48 49 59 public static List propertyDescriptors(int apiLevel) { 60 return PROPERTY_DESCRIPTORS; 61 } 62 63 67 private Name typeName = null; 68 69 78 SimpleType(AST ast) { 79 super(ast); 80 } 81 82 85 final List internalStructuralPropertiesForType(int apiLevel) { 86 return propertyDescriptors(apiLevel); 87 } 88 89 92 final ASTNode internalGetSetChildProperty(ChildPropertyDescriptor property, boolean get, ASTNode child) { 93 if (property == NAME_PROPERTY) { 94 if (get) { 95 return getName(); 96 } else { 97 setName((Name) child); 98 return null; 99 } 100 } 101 return super.internalGetSetChildProperty(property, get, child); 103 } 104 105 108 final int getNodeType0() { 109 return SIMPLE_TYPE; 110 } 111 112 115 ASTNode clone0(AST target) { 116 SimpleType result = new SimpleType(target); 117 result.setSourceRange(this.getStartPosition(), this.getLength()); 118 result.setName((Name) (getName()).clone(target)); 119 return result; 120 } 121 122 125 final boolean subtreeMatch0(ASTMatcher matcher, Object other) { 126 return matcher.match(this, other); 128 } 129 130 133 void accept0(ASTVisitor visitor) { 134 boolean visitChildren = visitor.visit(this); 135 if (visitChildren) { 136 acceptChild(visitor, getName()); 137 } 138 visitor.endVisit(this); 139 } 140 141 146 public Name getName() { 147 if (this.typeName == null) { 148 synchronized (this) { 150 if (this.typeName == null) { 151 preLazyInit(); 152 this.typeName = new SimpleName(this.ast); 153 postLazyInit(this.typeName, NAME_PROPERTY); 154 } 155 } 156 } 157 return this.typeName; 158 } 159 160 170 public void setName(Name typeName) { 171 if (typeName == null) { 172 throw new IllegalArgumentException (); 173 } 174 ASTNode oldChild = this.typeName; 175 preReplaceChild(oldChild, typeName, NAME_PROPERTY); 176 this.typeName = typeName; 177 postReplaceChild(oldChild, typeName, NAME_PROPERTY); 178 } 179 180 183 int memSize() { 184 return BASE_NODE_SIZE + 1 * 4; 186 } 187 188 191 int treeSize() { 192 return 193 memSize() 194 + (this.typeName == null ? 0 : getName().treeSize()); 195 } 196 } 197 198 | Popular Tags |