1 11 12 package org.eclipse.jdt.core.dom; 13 14 import java.util.ArrayList ; 15 import java.util.List ; 16 17 27 public class TypeLiteral extends Expression { 28 29 33 public static final ChildPropertyDescriptor TYPE_PROPERTY = 34 new ChildPropertyDescriptor(TypeLiteral.class, "type", Type.class, MANDATORY, CYCLE_RISK); 36 41 private static final List PROPERTY_DESCRIPTORS; 42 43 static { 44 List propertyList = new ArrayList (2); 45 createPropertyList(TypeLiteral.class, propertyList); 46 addProperty(TYPE_PROPERTY, propertyList); 47 PROPERTY_DESCRIPTORS = reapPropertyList(propertyList); 48 } 49 50 60 public static List propertyDescriptors(int apiLevel) { 61 return PROPERTY_DESCRIPTORS; 62 } 63 64 68 private Type type = null; 69 70 79 TypeLiteral(AST ast) { 80 super(ast); 81 } 82 83 86 final List internalStructuralPropertiesForType(int apiLevel) { 87 return propertyDescriptors(apiLevel); 88 } 89 90 93 final ASTNode internalGetSetChildProperty(ChildPropertyDescriptor property, boolean get, ASTNode child) { 94 if (property == TYPE_PROPERTY) { 95 if (get) { 96 return getType(); 97 } else { 98 setType((Type) child); 99 return null; 100 } 101 } 102 return super.internalGetSetChildProperty(property, get, child); 104 } 105 106 109 final int getNodeType0() { 110 return TYPE_LITERAL; 111 } 112 113 116 ASTNode clone0(AST target) { 117 TypeLiteral result = new TypeLiteral(target); 118 result.setSourceRange(this.getStartPosition(), this.getLength()); 119 result.setType((Type) getType().clone(target)); 120 return result; 121 } 122 123 126 final boolean subtreeMatch0(ASTMatcher matcher, Object other) { 127 return matcher.match(this, other); 129 } 130 131 134 void accept0(ASTVisitor visitor) { 135 boolean visitChildren = visitor.visit(this); 136 if (visitChildren) { 137 acceptChild(visitor, getType()); 138 } 139 visitor.endVisit(this); 140 } 141 142 147 public Type getType() { 148 if (this.type == null) { 149 synchronized (this) { 151 if (this.type == null) { 152 preLazyInit(); 153 this.type = this.ast.newPrimitiveType(PrimitiveType.INT); 154 postLazyInit(this.type, TYPE_PROPERTY); 155 } 156 } 157 } 158 return this.type; 159 } 160 161 171 public void setType(Type type) { 172 if (type == null) { 173 throw new IllegalArgumentException (); 174 } 175 ASTNode oldChild = this.type; 176 preReplaceChild(oldChild, type, TYPE_PROPERTY); 177 this.type = type; 178 postReplaceChild(oldChild, type, TYPE_PROPERTY); 179 } 180 181 184 int memSize() { 185 return BASE_NODE_SIZE + 1 * 4; 187 } 188 189 192 int treeSize() { 193 return 194 memSize() 195 + (this.type == null ? 0 : getType().treeSize()); 196 } 197 } 198 199 | Popular Tags |