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 ReturnStatement extends Statement { 28 29 33 public static final ChildPropertyDescriptor EXPRESSION_PROPERTY = 34 new ChildPropertyDescriptor(ReturnStatement.class, "expression", Expression.class, OPTIONAL, CYCLE_RISK); 36 41 private static final List PROPERTY_DESCRIPTORS; 42 43 static { 44 List propertyList = new ArrayList (2); 45 createPropertyList(ReturnStatement.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 67 private Expression optionalExpression = null; 68 69 75 ReturnStatement(AST ast) { 76 super(ast); 77 } 78 79 82 final List internalStructuralPropertiesForType(int apiLevel) { 83 return propertyDescriptors(apiLevel); 84 } 85 86 89 final ASTNode internalGetSetChildProperty(ChildPropertyDescriptor property, boolean get, ASTNode child) { 90 if (property == EXPRESSION_PROPERTY) { 91 if (get) { 92 return getExpression(); 93 } else { 94 setExpression((Expression) child); 95 return null; 96 } 97 } 98 return super.internalGetSetChildProperty(property, get, child); 100 } 101 102 105 final int getNodeType0() { 106 return RETURN_STATEMENT; 107 } 108 109 112 ASTNode clone0(AST target) { 113 ReturnStatement result = new ReturnStatement(target); 114 result.setSourceRange(this.getStartPosition(), this.getLength()); 115 result.copyLeadingComment(this); 116 result.setExpression( 117 (Expression) ASTNode.copySubtree(target, getExpression())); 118 return result; 119 } 120 121 124 final boolean subtreeMatch0(ASTMatcher matcher, Object other) { 125 return matcher.match(this, other); 127 } 128 129 132 void accept0(ASTVisitor visitor) { 133 boolean visitChildren = visitor.visit(this); 134 if (visitChildren) { 135 acceptChild(visitor, getExpression()); 136 } 137 visitor.endVisit(this); 138 } 139 140 146 public Expression getExpression() { 147 return this.optionalExpression; 148 } 149 150 162 public void setExpression(Expression expression) { 163 ASTNode oldChild = this.optionalExpression; 164 preReplaceChild(oldChild, expression, EXPRESSION_PROPERTY); 165 this.optionalExpression = expression; 166 postReplaceChild(oldChild, expression, EXPRESSION_PROPERTY); 167 } 168 169 172 int memSize() { 173 return super.memSize() + 1 * 4; 174 } 175 176 179 int treeSize() { 180 return 181 memSize() 182 + (this.optionalExpression == null ? 0 : getExpression().treeSize()); 183 } 184 } 185 186 | Popular Tags |