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 ParenthesizedExpression extends Expression { 28 29 33 public static final ChildPropertyDescriptor EXPRESSION_PROPERTY = 34 new ChildPropertyDescriptor(ParenthesizedExpression.class, "expression", Expression.class, MANDATORY, CYCLE_RISK); 36 41 private static final List PROPERTY_DESCRIPTORS; 42 43 static { 44 List propertyList = new ArrayList (2); 45 createPropertyList(ParenthesizedExpression.class, propertyList); 46 addProperty(EXPRESSION_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 Expression expression = null; 69 70 80 ParenthesizedExpression(AST ast) { 81 super(ast); 82 } 83 84 87 final List internalStructuralPropertiesForType(int apiLevel) { 88 return propertyDescriptors(apiLevel); 89 } 90 91 94 final ASTNode internalGetSetChildProperty(ChildPropertyDescriptor property, boolean get, ASTNode child) { 95 if (property == EXPRESSION_PROPERTY) { 96 if (get) { 97 return getExpression(); 98 } else { 99 setExpression((Expression) child); 100 return null; 101 } 102 } 103 return super.internalGetSetChildProperty(property, get, child); 105 } 106 107 110 final int getNodeType0() { 111 return PARENTHESIZED_EXPRESSION; 112 } 113 114 117 ASTNode clone0(AST target) { 118 ParenthesizedExpression result = new ParenthesizedExpression(target); 119 result.setSourceRange(this.getStartPosition(), this.getLength()); 120 result.setExpression((Expression) getExpression().clone(target)); 121 return result; 122 } 123 124 127 final boolean subtreeMatch0(ASTMatcher matcher, Object other) { 128 return matcher.match(this, other); 130 } 131 132 135 void accept0(ASTVisitor visitor) { 136 boolean visitChildren = visitor.visit(this); 137 if (visitChildren) { 138 acceptChild(visitor, getExpression()); 139 } 140 visitor.endVisit(this); 141 } 142 143 148 public Expression getExpression() { 149 if (this.expression == null) { 150 synchronized (this) { 152 if (this.expression == null) { 153 preLazyInit(); 154 this.expression = new SimpleName(this.ast); 155 postLazyInit(this.expression, EXPRESSION_PROPERTY); 156 } 157 } 158 } 159 return this.expression; 160 } 161 162 173 public void setExpression(Expression expression) { 174 if (expression == null) { 175 throw new IllegalArgumentException (); 176 } 177 ASTNode oldChild = this.expression; 178 preReplaceChild(oldChild, expression, EXPRESSION_PROPERTY); 179 this.expression = expression; 180 postReplaceChild(oldChild, expression, EXPRESSION_PROPERTY); 181 } 182 183 186 int memSize() { 187 return BASE_NODE_SIZE + 1 * 4; 188 } 189 190 193 int treeSize() { 194 return 195 memSize() 196 + (this.expression == null ? 0 : getExpression().treeSize()); 197 } 198 } 199 200 | Popular Tags |