View | Details | Raw Unified | Return to bug 88548 | Differences between
and this patch

Collapse All | Expand All

(-)ASTConverter.java (-1 / +109 lines)
Lines 44-52 Link Here
44
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
44
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
45
import org.eclipse.jdt.internal.compiler.env.IConstants;
45
import org.eclipse.jdt.internal.compiler.env.IConstants;
46
import org.eclipse.jdt.internal.compiler.env.IGenericType;
46
import org.eclipse.jdt.internal.compiler.env.IGenericType;
47
import org.eclipse.jdt.internal.compiler.impl.Constant;
47
import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
48
import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
48
import org.eclipse.jdt.internal.compiler.lookup.CompilerModifiers;
49
import org.eclipse.jdt.internal.compiler.lookup.CompilerModifiers;
49
import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
50
import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
51
import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
50
import org.eclipse.jdt.internal.compiler.parser.Scanner;
52
import org.eclipse.jdt.internal.compiler.parser.Scanner;
51
import org.eclipse.jdt.internal.compiler.parser.TerminalTokens;
53
import org.eclipse.jdt.internal.compiler.parser.TerminalTokens;
52
54
Lines 886-891 Link Here
886
		if (this.resolveBindings) {
888
		if (this.resolveBindings) {
887
			this.recordNodes(infixExpression, expression);
889
			this.recordNodes(infixExpression, expression);
888
		}
890
		}
891
		// https://bugs.eclipse.org/bugs/show_bug.cgi?id=88548
892
		final Constant constant = expression.constant;
893
		if (constant != null && constant != Constant.NotAConstant) {
894
			infixExpression.constant = convert(constant);
895
		}
889
896
890
		int expressionOperatorID = (expression.bits & org.eclipse.jdt.internal.compiler.ast.ASTNode.OperatorMASK) >> org.eclipse.jdt.internal.compiler.ast.ASTNode.OperatorSHIFT;
897
		int expressionOperatorID = (expression.bits & org.eclipse.jdt.internal.compiler.ast.ASTNode.OperatorMASK) >> org.eclipse.jdt.internal.compiler.ast.ASTNode.OperatorSHIFT;
891
		switch (expressionOperatorID) {
898
		switch (expressionOperatorID) {
Lines 1088-1093 Link Here
1088
		if (this.resolveBindings) {
1095
		if (this.resolveBindings) {
1089
			recordNodes(castExpression, expression);
1096
			recordNodes(castExpression, expression);
1090
		}
1097
		}
1098
		// https://bugs.eclipse.org/bugs/show_bug.cgi?id=88548
1099
		final Constant constant = expression.constant;
1100
		if (constant != null && constant != Constant.NotAConstant) {
1101
			castExpression.constant = convert(constant);
1102
		}
1091
		return castExpression;
1103
		return castExpression;
1092
	}
1104
	}
1093
1105
Lines 1103-1108 Link Here
1103
		literal.setEscapedValue(new String(tokens));
1115
		literal.setEscapedValue(new String(tokens));
1104
		literal.setSourceRange(sourceStart, length);
1116
		literal.setSourceRange(sourceStart, length);
1105
		removeLeadingAndTrailingCommentsFromLiteral(literal);
1117
		removeLeadingAndTrailingCommentsFromLiteral(literal);
1118
		// https://bugs.eclipse.org/bugs/show_bug.cgi?id=88548
1119
		final Constant constant = expression.constant;
1120
		if (constant != null && constant != Constant.NotAConstant) {
1121
			literal.constant = convert(constant);
1122
		}
1106
		return literal;
1123
		return literal;
1107
	}
1124
	}
1108
	public Expression convert(org.eclipse.jdt.internal.compiler.ast.ClassLiteralAccess expression) {
1125
	public Expression convert(org.eclipse.jdt.internal.compiler.ast.ClassLiteralAccess expression) {
Lines 1234-1239 Link Here
1234
		conditionalExpression.setExpression(convert(expression.condition));
1251
		conditionalExpression.setExpression(convert(expression.condition));
1235
		conditionalExpression.setThenExpression(convert(expression.valueIfTrue));
1252
		conditionalExpression.setThenExpression(convert(expression.valueIfTrue));
1236
		conditionalExpression.setElseExpression(convert(expression.valueIfFalse));
1253
		conditionalExpression.setElseExpression(convert(expression.valueIfFalse));
1254
		// https://bugs.eclipse.org/bugs/show_bug.cgi?id=88548
1255
		final Constant constant = expression.constant;
1256
		if (constant != null && constant != Constant.NotAConstant) {
1257
			conditionalExpression.constant = convert(constant);
1258
		}
1237
		return conditionalExpression;
1259
		return conditionalExpression;
1238
	}
1260
	}
1239
1261
Lines 1248-1253 Link Here
1248
		retrieveSemiColonPosition(continueStatement);
1270
		retrieveSemiColonPosition(continueStatement);
1249
		return continueStatement;
1271
		return continueStatement;
1250
	}
1272
	}
1273
1274
	private Object convert(Constant constant) {
1275
		switch (constant.typeID()) {
1276
			case TypeIds.T_int : return new Integer(constant.intValue());
1277
			case TypeIds.T_byte : return new Byte(constant.byteValue());
1278
			case TypeIds.T_short : return new Short(constant.shortValue());
1279
			case TypeIds.T_char : return new Character(constant.charValue());
1280
			case TypeIds.T_float : return new Float(constant.floatValue());
1281
			case TypeIds.T_double : return new Double(constant.doubleValue());
1282
			case TypeIds.T_boolean : return constant.booleanValue() ? Boolean.TRUE : Boolean.FALSE;
1283
			case TypeIds.T_long : return new Long(constant.longValue());
1284
			case TypeIds.T_JavaLangString : return constant.stringValue();
1285
		}
1286
		return null;
1287
	}
1251
	
1288
	
1252
	public DoStatement convert(org.eclipse.jdt.internal.compiler.ast.DoStatement statement) {
1289
	public DoStatement convert(org.eclipse.jdt.internal.compiler.ast.DoStatement statement) {
1253
		DoStatement doStatement = this.ast.newDoStatement();
1290
		DoStatement doStatement = this.ast.newDoStatement();
Lines 1269-1274 Link Here
1269
		}
1306
		}
1270
		literal.setSourceRange(sourceStart, length);
1307
		literal.setSourceRange(sourceStart, length);
1271
		removeLeadingAndTrailingCommentsFromLiteral(literal);
1308
		removeLeadingAndTrailingCommentsFromLiteral(literal);
1309
		// https://bugs.eclipse.org/bugs/show_bug.cgi?id=88548
1310
		final Constant constant = expression.constant;
1311
		if (constant != null && constant != Constant.NotAConstant) {
1312
			literal.constant = convert(constant);
1313
		}
1272
		return literal;
1314
		return literal;
1273
	}
1315
	}
1274
	
1316
	
Lines 1330-1335 Link Here
1330
		if (this.resolveBindings) {
1372
		if (this.resolveBindings) {
1331
			recordNodes(infixExpression, expression);
1373
			recordNodes(infixExpression, expression);
1332
		}
1374
		}
1375
		// https://bugs.eclipse.org/bugs/show_bug.cgi?id=88548
1376
		final Constant constant = expression.constant;
1377
		if (constant != null && constant != Constant.NotAConstant) {
1378
			infixExpression.constant = convert(expression.constant);
1379
		}
1333
		Expression leftExpression = convert(expression.left);
1380
		Expression leftExpression = convert(expression.left);
1334
		infixExpression.setLeftOperand(leftExpression);
1381
		infixExpression.setLeftOperand(leftExpression);
1335
		infixExpression.setRightOperand(convert(expression.right));
1382
		infixExpression.setRightOperand(convert(expression.right));
Lines 1567-1572 Link Here
1567
				recordNodes(simpleName, reference);
1614
				recordNodes(simpleName, reference);
1568
			}
1615
			}
1569
			superFieldAccess.setSourceRange(reference.receiver.sourceStart, reference.sourceEnd - reference.receiver.sourceStart + 1);
1616
			superFieldAccess.setSourceRange(reference.receiver.sourceStart, reference.sourceEnd - reference.receiver.sourceStart + 1);
1617
			// https://bugs.eclipse.org/bugs/show_bug.cgi?id=88548
1618
			final Constant constant = reference.constant;
1619
			if (constant != null && constant != Constant.NotAConstant) {
1620
				superFieldAccess.constant = convert(constant);
1621
			}
1570
			return superFieldAccess;
1622
			return superFieldAccess;
1571
		} else {
1623
		} else {
1572
			FieldAccess fieldAccess = this.ast.newFieldAccess();
1624
			FieldAccess fieldAccess = this.ast.newFieldAccess();
Lines 1584-1589 Link Here
1584
				recordNodes(simpleName, reference);
1636
				recordNodes(simpleName, reference);
1585
			}
1637
			}
1586
			fieldAccess.setSourceRange(receiver.getStartPosition(), reference.sourceEnd - receiver.getStartPosition() + 1);
1638
			fieldAccess.setSourceRange(receiver.getStartPosition(), reference.sourceEnd - receiver.getStartPosition() + 1);
1639
			// https://bugs.eclipse.org/bugs/show_bug.cgi?id=88548
1640
			final Constant constant = reference.constant;
1641
			if (constant != null && constant != Constant.NotAConstant) {
1642
				fieldAccess.constant = convert(constant);
1643
			}
1587
			return fieldAccess;
1644
			return fieldAccess;
1588
		}
1645
		}
1589
	}
1646
	}
Lines 1599-1604 Link Here
1599
		}
1656
		}
1600
		literal.setSourceRange(sourceStart, length);
1657
		literal.setSourceRange(sourceStart, length);
1601
		removeLeadingAndTrailingCommentsFromLiteral(literal);
1658
		removeLeadingAndTrailingCommentsFromLiteral(literal);
1659
		// https://bugs.eclipse.org/bugs/show_bug.cgi?id=88548
1660
		final Constant constant = expression.constant;
1661
		if (constant != null && constant != Constant.NotAConstant) {
1662
			literal.constant = convert(constant);
1663
		}
1602
		return literal;
1664
		return literal;
1603
	}
1665
	}
1604
	
1666
	
Lines 1699-1704 Link Here
1699
		}
1761
		}
1700
		literal.setSourceRange(sourceStart, length);
1762
		literal.setSourceRange(sourceStart, length);
1701
		removeLeadingAndTrailingCommentsFromLiteral(literal);
1763
		removeLeadingAndTrailingCommentsFromLiteral(literal);
1764
		// https://bugs.eclipse.org/bugs/show_bug.cgi?id=88548
1765
		final Constant constant = expression.constant;
1766
		if (constant != null && constant != Constant.NotAConstant) {
1767
			literal.constant = convert(constant);
1768
		}
1702
		return literal;
1769
		return literal;
1703
	}
1770
	}
1704
1771
Lines 1713-1718 Link Here
1713
		}
1780
		}
1714
		literal.setSourceRange(sourceStart, length);
1781
		literal.setSourceRange(sourceStart, length);
1715
		removeLeadingAndTrailingCommentsFromLiteral(literal);
1782
		removeLeadingAndTrailingCommentsFromLiteral(literal);
1783
		// https://bugs.eclipse.org/bugs/show_bug.cgi?id=88548
1784
		final Constant constant = expression.constant;
1785
		if (constant != null && constant != Constant.NotAConstant) {
1786
			literal.constant = convert(constant);
1787
		}
1716
		return literal;
1788
		return literal;
1717
	}
1789
	}
1718
1790
Lines 1761-1766 Link Here
1761
		}
1833
		}
1762
		literal.setSourceRange(sourceStart, length);
1834
		literal.setSourceRange(sourceStart, length);
1763
		removeLeadingAndTrailingCommentsFromLiteral(literal);
1835
		removeLeadingAndTrailingCommentsFromLiteral(literal);
1836
		// https://bugs.eclipse.org/bugs/show_bug.cgi?id=88548
1837
		final Constant constant = expression.constant;
1838
		if (constant != null && constant != Constant.NotAConstant) {
1839
			literal.constant = convert(constant);
1840
		}
1764
		return literal;
1841
		return literal;
1765
	}
1842
	}
1766
1843
Lines 1775-1780 Link Here
1775
		}
1852
		}
1776
		literal.setSourceRange(sourceStart, length);
1853
		literal.setSourceRange(sourceStart, length);
1777
		removeLeadingAndTrailingCommentsFromLiteral(literal);
1854
		removeLeadingAndTrailingCommentsFromLiteral(literal);
1855
		// https://bugs.eclipse.org/bugs/show_bug.cgi?id=88548
1856
		final Constant constant = expression.constant;
1857
		if (constant != null && constant != Constant.NotAConstant) {
1858
			literal.constant = convert(constant);
1859
		}
1778
		return literal;
1860
		return literal;
1779
	}
1861
	}
1780
1862
Lines 1948-1953 Link Here
1948
			this.recordNodes(infixExpression, expression);
2030
			this.recordNodes(infixExpression, expression);
1949
		}
2031
		}
1950
		infixExpression.setSourceRange(expression.sourceStart, expression.sourceEnd - expression.sourceStart + 1);
2032
		infixExpression.setSourceRange(expression.sourceStart, expression.sourceEnd - expression.sourceStart + 1);
2033
		// https://bugs.eclipse.org/bugs/show_bug.cgi?id=88548
2034
		final Constant constant = expression.constant;
2035
		if (constant != null && constant != Constant.NotAConstant) {
2036
			infixExpression.constant = convert(constant);
2037
		}
1951
		return infixExpression;
2038
		return infixExpression;
1952
	}
2039
	}
1953
	
2040
	
Lines 2088-2094 Link Here
2088
	}
2175
	}
2089
2176
2090
	public Name convert(org.eclipse.jdt.internal.compiler.ast.QualifiedNameReference nameReference) {
2177
	public Name convert(org.eclipse.jdt.internal.compiler.ast.QualifiedNameReference nameReference) {
2091
		return setQualifiedNameNameAndSourceRanges(nameReference.tokens, nameReference.sourcePositions, nameReference);
2178
		Name name = setQualifiedNameNameAndSourceRanges(nameReference.tokens, nameReference.sourcePositions, nameReference);
2179
		// https://bugs.eclipse.org/bugs/show_bug.cgi?id=88548
2180
		final Constant constant = nameReference.constant;
2181
		if (constant != null && constant != Constant.NotAConstant) {
2182
			name.constant = convert(constant);
2183
		}
2184
		return name;
2092
	}
2185
	}
2093
2186
2094
	public Name convert(org.eclipse.jdt.internal.compiler.ast.QualifiedSuperReference reference) {
2187
	public Name convert(org.eclipse.jdt.internal.compiler.ast.QualifiedSuperReference reference) {
Lines 2151-2156 Link Here
2151
			recordNodes(name, nameReference);
2244
			recordNodes(name, nameReference);
2152
		}
2245
		}
2153
		name.setSourceRange(nameReference.sourceStart, nameReference.sourceEnd - nameReference.sourceStart + 1);
2246
		name.setSourceRange(nameReference.sourceStart, nameReference.sourceEnd - nameReference.sourceStart + 1);
2247
		// https://bugs.eclipse.org/bugs/show_bug.cgi?id=88548
2248
		final Constant constant = nameReference.constant;
2249
		if (constant != null && constant != Constant.NotAConstant) {
2250
			name.constant = convert(constant);
2251
		}
2154
		return name;
2252
		return name;
2155
	}
2253
	}
2156
2254
Lines 2284-2289 Link Here
2284
		}
2382
		}
2285
		literal.setEscapedValue(new String(tokens));
2383
		literal.setEscapedValue(new String(tokens));
2286
		literal.setSourceRange(expression.sourceStart, expression.sourceEnd - expression.sourceStart + 1);
2384
		literal.setSourceRange(expression.sourceStart, expression.sourceEnd - expression.sourceStart + 1);
2385
		// https://bugs.eclipse.org/bugs/show_bug.cgi?id=88548
2386
		final Constant constant = expression.constant;
2387
		if (constant != null && constant != Constant.NotAConstant) {
2388
			literal.constant = convert(constant);
2389
		}
2287
		return literal;
2390
		return literal;
2288
	}
2391
	}
2289
	
2392
	
Lines 2518-2523 Link Here
2518
				break;
2621
				break;
2519
			case org.eclipse.jdt.internal.compiler.ast.OperatorIds.TWIDDLE :
2622
			case org.eclipse.jdt.internal.compiler.ast.OperatorIds.TWIDDLE :
2520
				prefixExpression.setOperator(PrefixExpression.Operator.COMPLEMENT);
2623
				prefixExpression.setOperator(PrefixExpression.Operator.COMPLEMENT);
2624
		}
2625
		// https://bugs.eclipse.org/bugs/show_bug.cgi?id=88548
2626
		final Constant constant = expression.constant;
2627
		if (constant != null && constant != Constant.NotAConstant) {
2628
			prefixExpression.constant = convert(constant);
2521
		}
2629
		}
2522
		return prefixExpression;
2630
		return prefixExpression;
2523
	}
2631
	}
(-)BooleanLiteral.java (-2 / +30 lines)
Lines 35-40 Link Here
35
		new SimplePropertyDescriptor(BooleanLiteral.class, "booleanValue", boolean.class, MANDATORY); //$NON-NLS-1$
35
		new SimplePropertyDescriptor(BooleanLiteral.class, "booleanValue", boolean.class, MANDATORY); //$NON-NLS-1$
36
	
36
	
37
	/**
37
	/**
38
	 * The "constant" structural property of this node type.
39
	 * @since 3.1
40
	 */
41
	public static final SimplePropertyDescriptor CONSTANT_PROPERTY = 
42
		new SimplePropertyDescriptor(BooleanLiteral.class, "constant", Object.class, MANDATORY); //$NON-NLS-1$
43
44
	/**
38
	 * A list of property descriptors (element type: 
45
	 * A list of property descriptors (element type: 
39
	 * {@link StructuralPropertyDescriptor}),
46
	 * {@link StructuralPropertyDescriptor}),
40
	 * or null if uninitialized.
47
	 * or null if uninitialized.
Lines 45-50 Link Here
45
		List properyList = new ArrayList(2);
52
		List properyList = new ArrayList(2);
46
		createPropertyList(BooleanLiteral.class, properyList);
53
		createPropertyList(BooleanLiteral.class, properyList);
47
		addProperty(BOOLEAN_VALUE_PROPERTY, properyList);
54
		addProperty(BOOLEAN_VALUE_PROPERTY, properyList);
55
		addProperty(CONSTANT_PROPERTY, properyList);
48
		PROPERTY_DESCRIPTORS = reapPropertyList(properyList);
56
		PROPERTY_DESCRIPTORS = reapPropertyList(properyList);
49
	}
57
	}
50
58
Lines 62-68 Link Here
62
	public static List propertyDescriptors(int apiLevel) {
70
	public static List propertyDescriptors(int apiLevel) {
63
		return PROPERTY_DESCRIPTORS;
71
		return PROPERTY_DESCRIPTORS;
64
	}
72
	}
65
			
73
66
	/**
74
	/**
67
	 * The boolean; defaults to the literal for <code>false</code>.
75
	 * The boolean; defaults to the literal for <code>false</code>.
68
	 */
76
	 */
Lines 103-108 Link Here
103
		return super.internalGetSetBooleanProperty(property, get, newValue);
111
		return super.internalGetSetBooleanProperty(property, get, newValue);
104
	}
112
	}
105
	
113
	
114
	/* (non-Javadoc)
115
	 * @see org.eclipse.jdt.core.dom.ASTNode#internalGetSetObjectProperty(org.eclipse.jdt.core.dom.SimplePropertyDescriptor, boolean, java.lang.Object)
116
	 */
117
	Object internalGetSetObjectProperty(SimplePropertyDescriptor property, boolean get, Object newValue) {
118
		if (property == CONSTANT_PROPERTY) {
119
			if (get) {
120
				return getConstant();
121
			} else {
122
				return null;
123
			}
124
		}
125
		return super.internalGetSetObjectProperty(property, get, newValue);
126
	}
106
	/* (omit javadoc for this method)
127
	/* (omit javadoc for this method)
107
	 * Method declared on ASTNode.
128
	 * Method declared on ASTNode.
108
	 */
129
	 */
Lines 146-152 Link Here
146
	public boolean booleanValue() {
167
	public boolean booleanValue() {
147
		return this.value;
168
		return this.value;
148
	}
169
	}
149
		
170
171
	/* (non-Javadoc)
172
	 * @see org.eclipse.jdt.core.dom.Expression#getConstant()
173
	 */
174
	public Object getConstant() {
175
		return this.value ? Boolean.TRUE : Boolean.FALSE;
176
	}
177
	
150
	/**
178
	/**
151
	 * Sets the boolean value of this boolean literal node.
179
	 * Sets the boolean value of this boolean literal node.
152
	 * 
180
	 * 
(-)CastExpression.java (-2 / +31 lines)
Lines 41-46 Link Here
41
		new ChildPropertyDescriptor(CastExpression.class, "expression", Expression.class, MANDATORY, CYCLE_RISK); //$NON-NLS-1$
41
		new ChildPropertyDescriptor(CastExpression.class, "expression", Expression.class, MANDATORY, CYCLE_RISK); //$NON-NLS-1$
42
42
43
	/**
43
	/**
44
	 * The "constant" structural property of this node type.
45
	 * @since 3.1
46
	 */
47
	public static final SimplePropertyDescriptor CONSTANT_PROPERTY = 
48
		new SimplePropertyDescriptor(CastExpression.class, "constant", Object.class, OPTIONAL); //$NON-NLS-1$
49
50
	/**
44
	 * A list of property descriptors (element type: 
51
	 * A list of property descriptors (element type: 
45
	 * {@link StructuralPropertyDescriptor}),
52
	 * {@link StructuralPropertyDescriptor}),
46
	 * or null if uninitialized.
53
	 * or null if uninitialized.
Lines 52-57 Link Here
52
		createPropertyList(CastExpression.class, properyList);
59
		createPropertyList(CastExpression.class, properyList);
53
		addProperty(TYPE_PROPERTY, properyList);
60
		addProperty(TYPE_PROPERTY, properyList);
54
		addProperty(EXPRESSION_PROPERTY, properyList);
61
		addProperty(EXPRESSION_PROPERTY, properyList);
62
		addProperty(CONSTANT_PROPERTY, properyList);
55
		PROPERTY_DESCRIPTORS = reapPropertyList(properyList);
63
		PROPERTY_DESCRIPTORS = reapPropertyList(properyList);
56
	}
64
	}
57
65
Lines 82-87 Link Here
82
	private Expression expression = null;
90
	private Expression expression = null;
83
91
84
	/**
92
	/**
93
	 * The constant value of this expression if it has one.
94
	 */
95
	Object constant;
96
	
97
	/**
85
	 * Creates a new AST node for a cast expression owned by the given 
98
	 * Creates a new AST node for a cast expression owned by the given 
86
	 * AST. By default, the type and expression are unspecified (but legal).
99
	 * AST. By default, the type and expression are unspecified (but legal).
87
	 * <p>
100
	 * <p>
Lines 124-130 Link Here
124
		// allow default implementation to flag the error
137
		// allow default implementation to flag the error
125
		return super.internalGetSetChildProperty(property, get, child);
138
		return super.internalGetSetChildProperty(property, get, child);
126
	}
139
	}
127
140
	
141
	/* (non-Javadoc)
142
	 * @see org.eclipse.jdt.core.dom.ASTNode#internalGetSetObjectProperty(org.eclipse.jdt.core.dom.SimplePropertyDescriptor, boolean, java.lang.Object)
143
	 */
144
	Object internalGetSetObjectProperty(SimplePropertyDescriptor property, boolean get, Object value) {
145
		if (property == CONSTANT_PROPERTY) {
146
			if (get) {
147
				return getConstant();
148
			} else {
149
				return null;
150
			}
151
		}
152
		return super.internalGetSetObjectProperty(property, get, value);
153
	}
128
	/* (omit javadoc for this method)
154
	/* (omit javadoc for this method)
129
	 * Method declared on ASTNode.
155
	 * Method declared on ASTNode.
130
	 */
156
	 */
Lines 203-208 Link Here
203
		postReplaceChild(oldChild, type, TYPE_PROPERTY);
229
		postReplaceChild(oldChild, type, TYPE_PROPERTY);
204
	}
230
	}
205
	
231
	
232
	public Object getConstant() {
233
		return this.constant;
234
	}
206
	/**
235
	/**
207
	 * Returns the expression of this cast expression.
236
	 * Returns the expression of this cast expression.
208
	 * 
237
	 * 
Lines 248-254 Link Here
248
	 */
277
	 */
249
	int memSize() {
278
	int memSize() {
250
		// treat Code as free
279
		// treat Code as free
251
		return BASE_NODE_SIZE + 2 * 4;
280
		return BASE_NODE_SIZE + 3 * 4;
252
	}
281
	}
253
	
282
	
254
	/* (omit javadoc for this method)
283
	/* (omit javadoc for this method)
(-)CharacterLiteral.java (-2 / +29 lines)
Lines 26-31 Link Here
26
public class CharacterLiteral extends Expression {
26
public class CharacterLiteral extends Expression {
27
27
28
	/**
28
	/**
29
	 * The "constant" structural property of this node type.
30
	 * @since 3.1
31
	 */
32
	public static final SimplePropertyDescriptor CONSTANT_PROPERTY = 
33
		new SimplePropertyDescriptor(CharacterLiteral.class, "constant", Object.class, MANDATORY); //$NON-NLS-1$
34
35
	/**
29
	 * The "escapedValue" structural property of this node type.
36
	 * The "escapedValue" structural property of this node type.
30
	 * @since 3.0
37
	 * @since 3.0
31
	 */
38
	 */
Lines 43-48 Link Here
43
		List properyList = new ArrayList(2);
50
		List properyList = new ArrayList(2);
44
		createPropertyList(CharacterLiteral.class, properyList);
51
		createPropertyList(CharacterLiteral.class, properyList);
45
		addProperty(ESCAPED_VALUE_PROPERTY, properyList);
52
		addProperty(ESCAPED_VALUE_PROPERTY, properyList);
53
		addProperty(CONSTANT_PROPERTY, properyList);
46
		PROPERTY_DESCRIPTORS = reapPropertyList(properyList);
54
		PROPERTY_DESCRIPTORS = reapPropertyList(properyList);
47
	}
55
	}
48
56
Lines 60-66 Link Here
60
	public static List propertyDescriptors(int apiLevel) {
68
	public static List propertyDescriptors(int apiLevel) {
61
		return PROPERTY_DESCRIPTORS;
69
		return PROPERTY_DESCRIPTORS;
62
	}
70
	}
63
			
71
72
	/**
73
	 * The constant value of this expression if it has one.
74
	 */
75
	Object constant;
76
64
	/**
77
	/**
65
	 * The literal string, including quotes and escapes; defaults to the 
78
	 * The literal string, including quotes and escapes; defaults to the 
66
	 * literal for the character 'X'.
79
	 * literal for the character 'X'.
Lines 99-104 Link Here
99
				return null;
112
				return null;
100
			}
113
			}
101
		}
114
		}
115
		if (property == CONSTANT_PROPERTY) {
116
			if (get) {
117
				return getConstant();
118
			} else {
119
				return null;
120
			}
121
		}
102
		// allow default implementation to flag the error
122
		// allow default implementation to flag the error
103
		return super.internalGetSetObjectProperty(property, get, value);
123
		return super.internalGetSetObjectProperty(property, get, value);
104
	}
124
	}
Lines 136-141 Link Here
136
		visitor.endVisit(this);
156
		visitor.endVisit(this);
137
	}
157
	}
138
	
158
	
159
	/* (non-Javadoc)
160
	 * @see org.eclipse.jdt.core.dom.Expression#getConstant()
161
	 */
162
	public Object getConstant() {
163
		return this.constant;
164
	}
165
139
	/**
166
	/**
140
	 * Returns the string value of this literal node. The value is the sequence
167
	 * Returns the string value of this literal node. The value is the sequence
141
	 * of characters that would appear in the source program, including
168
	 * of characters that would appear in the source program, including
Lines 359-365 Link Here
359
	 * Method declared on ASTNode.
386
	 * Method declared on ASTNode.
360
	 */
387
	 */
361
	int memSize() {
388
	int memSize() {
362
		int size = BASE_NODE_SIZE + 1 * 4 + stringSize(escapedValue);
389
		int size = BASE_NODE_SIZE + 2 * 4 + stringSize(escapedValue);
363
		return size;
390
		return size;
364
	}
391
	}
365
	
392
	
(-)ConditionalExpression.java (-3 / +38 lines)
Lines 27-32 Link Here
27
public class ConditionalExpression extends Expression {
27
public class ConditionalExpression extends Expression {
28
	
28
	
29
	/**
29
	/**
30
	 * The "constant" structural property of this node type.
31
	 * @since 3.1
32
	 */
33
	public static final SimplePropertyDescriptor CONSTANT_PROPERTY = 
34
		new SimplePropertyDescriptor(ConditionalExpression.class, "constant", Object.class, OPTIONAL); //$NON-NLS-1$
35
36
	/**
30
	 * The "expression" structural property of this node type.
37
	 * The "expression" structural property of this node type.
31
	 * @since 3.0
38
	 * @since 3.0
32
	 */
39
	 */
Lines 60-65 Link Here
60
		addProperty(EXPRESSION_PROPERTY, properyList);
67
		addProperty(EXPRESSION_PROPERTY, properyList);
61
		addProperty(THEN_EXPRESSION_PROPERTY, properyList);
68
		addProperty(THEN_EXPRESSION_PROPERTY, properyList);
62
		addProperty(ELSE_EXPRESSION_PROPERTY, properyList);
69
		addProperty(ELSE_EXPRESSION_PROPERTY, properyList);
70
		addProperty(CONSTANT_PROPERTY, properyList);
63
		PROPERTY_DESCRIPTORS = reapPropertyList(properyList);
71
		PROPERTY_DESCRIPTORS = reapPropertyList(properyList);
64
	}
72
	}
65
73
Lines 77-83 Link Here
77
	public static List propertyDescriptors(int apiLevel) {
85
	public static List propertyDescriptors(int apiLevel) {
78
		return PROPERTY_DESCRIPTORS;
86
		return PROPERTY_DESCRIPTORS;
79
	}
87
	}
80
			
88
	
89
	/**
90
	 * The constant value of this expression if it has one.
91
	 */
92
	Object constant;
93
81
	/**
94
	/**
82
	 * The condition expression; lazily initialized; defaults to an unspecified,
95
	 * The condition expression; lazily initialized; defaults to an unspecified,
83
	 * but legal, expression.
96
	 * but legal, expression.
Lines 148-154 Link Here
148
		// allow default implementation to flag the error
161
		// allow default implementation to flag the error
149
		return super.internalGetSetChildProperty(property, get, child);
162
		return super.internalGetSetChildProperty(property, get, child);
150
	}
163
	}
151
	
164
165
	/* (non-Javadoc)
166
	 * @see org.eclipse.jdt.core.dom.ASTNode#internalGetSetObjectProperty(org.eclipse.jdt.core.dom.SimplePropertyDescriptor, boolean, java.lang.Object)
167
	 */
168
	Object internalGetSetObjectProperty(SimplePropertyDescriptor property, boolean get, Object value) {
169
		if (property == CONSTANT_PROPERTY) {
170
			if (get) {
171
				return getConstant();
172
			} else {
173
				return null;
174
			}
175
		}
176
		return super.internalGetSetObjectProperty(property, get, value);
177
	}
178
152
	/* (omit javadoc for this method)
179
	/* (omit javadoc for this method)
153
	 * Method declared on ASTNode.
180
	 * Method declared on ASTNode.
154
	 */
181
	 */
Lines 192-197 Link Here
192
		visitor.endVisit(this);
219
		visitor.endVisit(this);
193
	}
220
	}
194
	
221
	
222
223
	/* (non-Javadoc)
224
	 * @see org.eclipse.jdt.core.dom.Expression#getConstant()
225
	 */
226
	public Object getConstant() {
227
		return this.constant;
228
	}
229
	
195
	/**
230
	/**
196
	 * Returns the condition of this conditional expression.
231
	 * Returns the condition of this conditional expression.
197
	 * 
232
	 * 
Lines 317-323 Link Here
317
	 */
352
	 */
318
	int memSize() {
353
	int memSize() {
319
		// treat Code as free
354
		// treat Code as free
320
		return BASE_NODE_SIZE + 3 * 4;
355
		return BASE_NODE_SIZE + 4 * 4;
321
	}
356
	}
322
	
357
	
323
	/* (omit javadoc for this method)
358
	/* (omit javadoc for this method)
(-)Expression.java (+17 lines)
Lines 63-68 Link Here
63
	}
63
	}
64
	
64
	
65
	/**
65
	/**
66
	 * Returns this expression's constant value if it has one.
67
	 * Some expressions may have a value computed at compile-time. If the type of
68
	 * the value is a primitive type, the result is the boxed equivalent (i.e.,
69
	 * int returned as an <code>Integer</code>). If the type of the value is
70
	 * <code>String</code>, the result is the string itself. If the variable has
71
	 * no compile-time computed value, the result is <code>null</code>.
72
	 * (Note: compile-time constant expressions cannot denote <code>null</code>;
73
	 * JLS2 15.28.). The result is always <code>null</code> for enum constants.
74
	 * 
75
	 * @return the constant value, or <code>null</code> if none
76
	 * @since 3.1
77
	 */
78
	public Object getConstant() {
79
		return null;
80
	}
81
82
	/**
66
	 * Resolves and returns the binding for the type of this expression.
83
	 * Resolves and returns the binding for the type of this expression.
67
	 * <p>
84
	 * <p>
68
	 * Note that bindings are generally unavailable unless requested when the
85
	 * Note that bindings are generally unavailable unless requested when the
(-)FieldAccess.java (-2 / +37 lines)
Lines 57-62 Link Here
57
public class FieldAccess extends Expression {
57
public class FieldAccess extends Expression {
58
	
58
	
59
	/**
59
	/**
60
	 * The "constant" structural property of this node type.
61
	 * @since 3.1
62
	 */
63
	public static final SimplePropertyDescriptor CONSTANT_PROPERTY = 
64
		new SimplePropertyDescriptor(FieldAccess.class, "constant", Object.class, OPTIONAL); //$NON-NLS-1$
65
66
	/**
60
	 * The "expression" structural property of this node type.
67
	 * The "expression" structural property of this node type.
61
	 * @since 3.0
68
	 * @since 3.0
62
	 */
69
	 */
Lines 82-87 Link Here
82
		createPropertyList(FieldAccess.class, properyList);
89
		createPropertyList(FieldAccess.class, properyList);
83
		addProperty(EXPRESSION_PROPERTY, properyList);
90
		addProperty(EXPRESSION_PROPERTY, properyList);
84
		addProperty(NAME_PROPERTY, properyList);
91
		addProperty(NAME_PROPERTY, properyList);
92
		addProperty(CONSTANT_PROPERTY, properyList);
85
		PROPERTY_DESCRIPTORS = reapPropertyList(properyList);
93
		PROPERTY_DESCRIPTORS = reapPropertyList(properyList);
86
	}
94
	}
87
95
Lines 99-105 Link Here
99
	public static List propertyDescriptors(int apiLevel) {
107
	public static List propertyDescriptors(int apiLevel) {
100
		return PROPERTY_DESCRIPTORS;
108
		return PROPERTY_DESCRIPTORS;
101
	}
109
	}
102
			
110
111
	/**
112
	 * The constant value of this expression if it has one.
113
	 */
114
	Object constant;
115
103
	/**
116
	/**
104
	 * The expression; lazily initialized; defaults to an unspecified,
117
	 * The expression; lazily initialized; defaults to an unspecified,
105
	 * but legal, simple name.
118
	 * but legal, simple name.
Lines 160-165 Link Here
160
	/* (omit javadoc for this method)
173
	/* (omit javadoc for this method)
161
	 * Method declared on ASTNode.
174
	 * Method declared on ASTNode.
162
	 */
175
	 */
176
	final Object internalGetSetObjectProperty(SimplePropertyDescriptor property, boolean get, ASTNode child) {
177
		if (property == CONSTANT_PROPERTY) {
178
			if (get) {
179
				return getConstant();
180
			} else {
181
				return null;
182
			}
183
		}
184
		// allow default implementation to flag the error
185
		return super.internalGetSetObjectProperty(property, get, child);
186
	}
187
	
188
	/* (omit javadoc for this method)
189
	 * Method declared on ASTNode.
190
	 */
163
	final int getNodeType0() {
191
	final int getNodeType0() {
164
		return FIELD_ACCESS;
192
		return FIELD_ACCESS;
165
	}
193
	}
Lines 196-201 Link Here
196
		visitor.endVisit(this);
224
		visitor.endVisit(this);
197
	}
225
	}
198
	
226
	
227
	/* (non-Javadoc)
228
	 * @see org.eclipse.jdt.core.dom.Expression#getConstant()
229
	 */
230
	public Object getConstant() {
231
		return this.constant;
232
	}
233
199
	/**
234
	/**
200
	 * Returns the expression of this field access expression.
235
	 * Returns the expression of this field access expression.
201
	 * 
236
	 * 
Lines 280-286 Link Here
280
	 */
315
	 */
281
	int memSize() {
316
	int memSize() {
282
		// treat Code as free
317
		// treat Code as free
283
		return BASE_NODE_SIZE + 2 * 4;
318
		return BASE_NODE_SIZE + 3 * 4;
284
	}
319
	}
285
	
320
	
286
	/**
321
	/**
(-)InfixExpression.java (-3 / +30 lines)
Lines 173-178 Link Here
173
	}
173
	}
174
	
174
	
175
	/**
175
	/**
176
	 * The "constant" structural property of this node type.
177
	 * @since 3.1
178
	 */
179
	public static final SimplePropertyDescriptor CONSTANT_PROPERTY = 
180
		new SimplePropertyDescriptor(InfixExpression.class, "constant", Object.class, OPTIONAL); //$NON-NLS-1$
181
182
	/**
176
	 * The "leftOperand" structural property of this node type.
183
	 * The "leftOperand" structural property of this node type.
177
	 * @since 3.0
184
	 * @since 3.0
178
	 */
185
	 */
Lines 214-219 Link Here
214
		addProperty(OPERATOR_PROPERTY, properyList);
221
		addProperty(OPERATOR_PROPERTY, properyList);
215
		addProperty(RIGHT_OPERAND_PROPERTY, properyList);
222
		addProperty(RIGHT_OPERAND_PROPERTY, properyList);
216
		addProperty(EXTENDED_OPERANDS_PROPERTY, properyList);
223
		addProperty(EXTENDED_OPERANDS_PROPERTY, properyList);
224
		addProperty(CONSTANT_PROPERTY, properyList);
217
		PROPERTY_DESCRIPTORS = reapPropertyList(properyList);
225
		PROPERTY_DESCRIPTORS = reapPropertyList(properyList);
218
	}
226
	}
219
227
Lines 231-237 Link Here
231
	public static List propertyDescriptors(int apiLevel) {
239
	public static List propertyDescriptors(int apiLevel) {
232
		return PROPERTY_DESCRIPTORS;
240
		return PROPERTY_DESCRIPTORS;
233
	}
241
	}
234
			
242
243
	/**
244
	 * The constant value of this expression if it has one.
245
	 */
246
	Object constant;
247
235
	/**
248
	/**
236
	 * The infix operator; defaults to InfixExpression.Operator.PLUS.
249
	 * The infix operator; defaults to InfixExpression.Operator.PLUS.
237
	 */
250
	 */
Lines 285-290 Link Here
285
				return null;
298
				return null;
286
			}
299
			}
287
		}
300
		}
301
		if (property == CONSTANT_PROPERTY) {
302
			if (get) {
303
				return getConstant();
304
			} else {
305
				return null;
306
			}
307
		}
288
		// allow default implementation to flag the error
308
		// allow default implementation to flag the error
289
		return super.internalGetSetObjectProperty(property, get, value);
309
		return super.internalGetSetObjectProperty(property, get, value);
290
	}
310
	}
Lines 372-378 Link Here
372
		}
392
		}
373
		visitor.endVisit(this);
393
		visitor.endVisit(this);
374
	}
394
	}
375
	
395
396
	/* (non-Javadoc)
397
	 * @see org.eclipse.jdt.core.dom.Expression#getConstant()
398
	 */
399
	public Object getConstant() {
400
		return this.constant;
401
	}
402
376
	/**
403
	/**
377
	 * Returns the operator of this infix expression.
404
	 * Returns the operator of this infix expression.
378
	 * 
405
	 * 
Lines 521-527 Link Here
521
	 */
548
	 */
522
	int memSize() {
549
	int memSize() {
523
		// treat Operator as free
550
		// treat Operator as free
524
		return BASE_NODE_SIZE + 4 * 4;
551
		return BASE_NODE_SIZE + 5 * 4;
525
	}
552
	}
526
	
553
	
527
	/* (omit javadoc for this method)
554
	/* (omit javadoc for this method)
(-)Name.java (-1 / +13 lines)
Lines 31-39 Link Here
31
	 * Approximate base size of an expression node instance in bytes, 
31
	 * Approximate base size of an expression node instance in bytes, 
32
	 * including object header and instance fields.
32
	 * including object header and instance fields.
33
	 */
33
	 */
34
	static final int BASE_NAME_NODE_SIZE = BASE_NODE_SIZE + 1 * 4;
34
	static final int BASE_NAME_NODE_SIZE = BASE_NODE_SIZE + 2 * 4;
35
	
35
	
36
	/**
36
	/**
37
	 * The constant value of this expression if it has one.
38
	 */
39
	Object constant;
40
41
	/**
37
	 * This index represents the position inside a qualified name.
42
	 * This index represents the position inside a qualified name.
38
	 */
43
	 */
39
	int index;
44
	int index;
Lines 50-55 Link Here
50
		super(ast);
55
		super(ast);
51
	}
56
	}
52
	
57
	
58
	/* (non-Javadoc)
59
	 * @see org.eclipse.jdt.core.dom.Expression#getConstant()
60
	 */
61
	public Object getConstant() {
62
		return this.constant;
63
	}
64
53
	/**
65
	/**
54
	 * Returns whether this name is a simple name
66
	 * Returns whether this name is a simple name
55
	 * (<code>SimpleName</code>).
67
	 * (<code>SimpleName</code>).
(-)NumberLiteral.java (-1 / +28 lines)
Lines 26-31 Link Here
26
public class NumberLiteral extends Expression {
26
public class NumberLiteral extends Expression {
27
27
28
	/**
28
	/**
29
	 * The "constant" structural property of this node type.
30
	 * @since 3.1
31
	 */
32
	public static final SimplePropertyDescriptor CONSTANT_PROPERTY = 
33
		new SimplePropertyDescriptor(NumberLiteral.class, "constant", Object.class, MANDATORY); //$NON-NLS-1$
34
35
	/**
29
	 * The "token" structural property of this node type.
36
	 * The "token" structural property of this node type.
30
	 * @since 3.0
37
	 * @since 3.0
31
	 */
38
	 */
Lines 43-48 Link Here
43
		List propertyList = new ArrayList(2);
50
		List propertyList = new ArrayList(2);
44
		createPropertyList(NumberLiteral.class, propertyList);
51
		createPropertyList(NumberLiteral.class, propertyList);
45
		addProperty(TOKEN_PROPERTY, propertyList);
52
		addProperty(TOKEN_PROPERTY, propertyList);
53
		addProperty(CONSTANT_PROPERTY, propertyList);
46
		PROPERTY_DESCRIPTORS = reapPropertyList(propertyList);
54
		PROPERTY_DESCRIPTORS = reapPropertyList(propertyList);
47
	}
55
	}
48
56
Lines 62-67 Link Here
62
	}
70
	}
63
			
71
			
64
	/**
72
	/**
73
	 * The constant value of this expression if it has one.
74
	 */
75
	Object constant;
76
77
	/**
65
	 * The token string; defaults to the integer literal "0".
78
	 * The token string; defaults to the integer literal "0".
66
	 */
79
	 */
67
	private String tokenValue = "0";//$NON-NLS-1$
80
	private String tokenValue = "0";//$NON-NLS-1$
Lines 98-103 Link Here
98
				return null;
111
				return null;
99
			}
112
			}
100
		}
113
		}
114
		if (property == CONSTANT_PROPERTY) {
115
			if (get) {
116
				return getConstant();
117
			} else {
118
				return null;
119
			}
120
		}
101
		// allow default implementation to flag the error
121
		// allow default implementation to flag the error
102
		return super.internalGetSetObjectProperty(property, get, value);
122
		return super.internalGetSetObjectProperty(property, get, value);
103
	}
123
	}
Lines 134-139 Link Here
134
		visitor.visit(this);
154
		visitor.visit(this);
135
		visitor.endVisit(this);
155
		visitor.endVisit(this);
136
	}
156
	}
157
158
	/* (non-Javadoc)
159
	 * @see org.eclipse.jdt.core.dom.Expression#getConstant()
160
	 */
161
	public Object getConstant() {
162
		return this.constant;
163
	}
137
	
164
	
138
	/**
165
	/**
139
	 * Returns the token of this number literal node. The value is the sequence
166
	 * Returns the token of this number literal node. The value is the sequence
Lines 200-206 Link Here
200
	 * Method declared on ASTNode.
227
	 * Method declared on ASTNode.
201
	 */
228
	 */
202
	int memSize() {
229
	int memSize() {
203
		int size = BASE_NODE_SIZE + 1 * 4 + stringSize(tokenValue);
230
		int size = BASE_NODE_SIZE + 2 * 4 + stringSize(tokenValue);
204
		return size;
231
		return size;
205
	}
232
	}
206
	
233
	
(-)PrefixExpression.java (-2 / +30 lines)
Lines 120-125 Link Here
120
	}
120
	}
121
	
121
	
122
	/**
122
	/**
123
	 * The "constant" structural property of this node type.
124
	 * @since 3.1
125
	 */
126
	public static final SimplePropertyDescriptor CONSTANT_PROPERTY = 
127
		new SimplePropertyDescriptor(PrefixExpression.class, "constant", Object.class, OPTIONAL); //$NON-NLS-1$
128
129
130
	/**
123
	 * The "operator" structural property of this node type.
131
	 * The "operator" structural property of this node type.
124
	 * @since 3.0
132
	 * @since 3.0
125
	 */
133
	 */
Lines 145-150 Link Here
145
		createPropertyList(PrefixExpression.class, propertyList);
153
		createPropertyList(PrefixExpression.class, propertyList);
146
		addProperty(OPERATOR_PROPERTY, propertyList);
154
		addProperty(OPERATOR_PROPERTY, propertyList);
147
		addProperty(OPERAND_PROPERTY, propertyList);
155
		addProperty(OPERAND_PROPERTY, propertyList);
156
		addProperty(CONSTANT_PROPERTY, propertyList);
148
		PROPERTY_DESCRIPTORS = reapPropertyList(propertyList);
157
		PROPERTY_DESCRIPTORS = reapPropertyList(propertyList);
149
	}
158
	}
150
159
Lines 162-168 Link Here
162
	public static List propertyDescriptors(int apiLevel) {
171
	public static List propertyDescriptors(int apiLevel) {
163
		return PROPERTY_DESCRIPTORS;
172
		return PROPERTY_DESCRIPTORS;
164
	}
173
	}
165
			
174
175
	/**
176
	 * The constant value of this expression if it has one.
177
	 */
178
	Object constant;
179
166
	/**
180
	/**
167
	 * The operator; defaults to an unspecified prefix operator.
181
	 * The operator; defaults to an unspecified prefix operator.
168
	 */
182
	 */
Lines 205-210 Link Here
205
				return null;
219
				return null;
206
			}
220
			}
207
		}
221
		}
222
		if (property == CONSTANT_PROPERTY) {
223
			if (get) {
224
				return getConstant();
225
			} else {
226
				return null;
227
			}
228
		}
208
		// allow default implementation to flag the error
229
		// allow default implementation to flag the error
209
		return super.internalGetSetObjectProperty(property, get, value);
230
		return super.internalGetSetObjectProperty(property, get, value);
210
	}
231
	}
Lines 263-268 Link Here
263
		visitor.endVisit(this);
284
		visitor.endVisit(this);
264
	}
285
	}
265
	
286
	
287
	/* (non-Javadoc)
288
	 * @see org.eclipse.jdt.core.dom.Expression#getConstant()
289
	 */
290
	public Object getConstant() {
291
		return this.constant;
292
	}
293
266
	/**
294
	/**
267
	 * Returns the operator of this prefix expression.
295
	 * Returns the operator of this prefix expression.
268
	 * 
296
	 * 
Lines 332-338 Link Here
332
	 */
360
	 */
333
	int memSize() {
361
	int memSize() {
334
		// treat Operator as free
362
		// treat Operator as free
335
		return BASE_NODE_SIZE + 2 * 4;
363
		return BASE_NODE_SIZE + 3 * 4;
336
	}
364
	}
337
	
365
	
338
	/* (omit javadoc for this method)
366
	/* (omit javadoc for this method)
(-)QualifiedName.java (+22 lines)
Lines 34-39 Link Here
34
public class QualifiedName extends Name {
34
public class QualifiedName extends Name {
35
	
35
	
36
	/**
36
	/**
37
	 * The "constant" structural property of this node type.
38
	 * @since 3.1
39
	 */
40
	public static final SimplePropertyDescriptor CONSTANT_PROPERTY = 
41
		new SimplePropertyDescriptor(QualifiedName.class, "constant", Object.class, OPTIONAL); //$NON-NLS-1$
42
43
	/**
37
	 * The "qualifier" structural property of this node type.
44
	 * The "qualifier" structural property of this node type.
38
	 * @since 3.0
45
	 * @since 3.0
39
	 */
46
	 */
Lines 59-64 Link Here
59
		createPropertyList(QualifiedName.class, propertyList);
66
		createPropertyList(QualifiedName.class, propertyList);
60
		addProperty(QUALIFIER_PROPERTY, propertyList);
67
		addProperty(QUALIFIER_PROPERTY, propertyList);
61
		addProperty(NAME_PROPERTY, propertyList);
68
		addProperty(NAME_PROPERTY, propertyList);
69
		addProperty(CONSTANT_PROPERTY, propertyList);
62
		PROPERTY_DESCRIPTORS = reapPropertyList(propertyList);
70
		PROPERTY_DESCRIPTORS = reapPropertyList(propertyList);
63
	}
71
	}
64
72
Lines 131-136 Link Here
131
		}
139
		}
132
		// allow default implementation to flag the error
140
		// allow default implementation to flag the error
133
		return super.internalGetSetChildProperty(property, get, child);
141
		return super.internalGetSetChildProperty(property, get, child);
142
	}
143
	
144
	/* (non-Javadoc)
145
	 * @see org.eclipse.jdt.core.dom.ASTNode#internalGetSetObjectProperty(org.eclipse.jdt.core.dom.SimplePropertyDescriptor, boolean, java.lang.Object)
146
	 */
147
	Object internalGetSetObjectProperty(SimplePropertyDescriptor property, boolean get, Object value) {
148
		if (property == CONSTANT_PROPERTY) {
149
			if (get) {
150
				return getConstant();
151
			} else {
152
				return null;
153
			}
154
		}
155
		return super.internalGetSetObjectProperty(property, get, value);
134
	}
156
	}
135
	
157
	
136
	/* (omit javadoc for this method)
158
	/* (omit javadoc for this method)
(-)SimpleName.java (+15 lines)
Lines 31-36 Link Here
31
public class SimpleName extends Name {
31
public class SimpleName extends Name {
32
32
33
	/**
33
	/**
34
	 * The "constant" structural property of this node type.
35
	 * @since 3.1
36
	 */
37
	public static final SimplePropertyDescriptor CONSTANT_PROPERTY = 
38
		new SimplePropertyDescriptor(SimpleName.class, "constant", Object.class, OPTIONAL); //$NON-NLS-1$
39
40
	/**
34
	 * The "identifier" structural property of this node type.
41
	 * The "identifier" structural property of this node type.
35
	 * 
42
	 * 
36
	 * @since 3.0
43
	 * @since 3.0
Lines 50-55 Link Here
50
		List propertyList = new ArrayList(2);
57
		List propertyList = new ArrayList(2);
51
		createPropertyList(SimpleName.class, propertyList);
58
		createPropertyList(SimpleName.class, propertyList);
52
		addProperty(IDENTIFIER_PROPERTY, propertyList);
59
		addProperty(IDENTIFIER_PROPERTY, propertyList);
60
		addProperty(CONSTANT_PROPERTY, propertyList);
53
		PROPERTY_DESCRIPTORS = reapPropertyList(propertyList);
61
		PROPERTY_DESCRIPTORS = reapPropertyList(propertyList);
54
	}
62
	}
55
	
63
	
Lines 108-113 Link Here
108
				return getIdentifier();
116
				return getIdentifier();
109
			} else {
117
			} else {
110
				setIdentifier((String) value);
118
				setIdentifier((String) value);
119
				return null;
120
			}
121
		}
122
		if (property == CONSTANT_PROPERTY) {
123
			if (get) {
124
				return getConstant();
125
			} else {
111
				return null;
126
				return null;
112
			}
127
			}
113
		}
128
		}
(-)StringLiteral.java (-2 / +29 lines)
Lines 26-31 Link Here
26
public class StringLiteral extends Expression {
26
public class StringLiteral extends Expression {
27
27
28
	/**
28
	/**
29
	 * The "constant" structural property of this node type.
30
	 * @since 3.1
31
	 */
32
	public static final SimplePropertyDescriptor CONSTANT_PROPERTY = 
33
		new SimplePropertyDescriptor(StringLiteral.class, "constant", Object.class, MANDATORY); //$NON-NLS-1$
34
35
	/**
29
	 * The "escapedValue" structural property of this node type.
36
	 * The "escapedValue" structural property of this node type.
30
	 * @since 3.0
37
	 * @since 3.0
31
	 */
38
	 */
Lines 43-48 Link Here
43
		List propertyList = new ArrayList(2);
50
		List propertyList = new ArrayList(2);
44
		createPropertyList(StringLiteral.class, propertyList);
51
		createPropertyList(StringLiteral.class, propertyList);
45
		addProperty(ESCAPED_VALUE_PROPERTY, propertyList);
52
		addProperty(ESCAPED_VALUE_PROPERTY, propertyList);
53
		addProperty(CONSTANT_PROPERTY, propertyList);
46
		PROPERTY_DESCRIPTORS = reapPropertyList(propertyList);
54
		PROPERTY_DESCRIPTORS = reapPropertyList(propertyList);
47
	}
55
	}
48
56
Lines 60-66 Link Here
60
	public static List propertyDescriptors(int apiLevel) {
68
	public static List propertyDescriptors(int apiLevel) {
61
		return PROPERTY_DESCRIPTORS;
69
		return PROPERTY_DESCRIPTORS;
62
	}
70
	}
63
			
71
72
	/**
73
	 * The constant value of this expression if it has one.
74
	 */
75
	Object constant;
76
64
	/**
77
	/**
65
	 * The literal string, including quotes and escapes; defaults to the 
78
	 * The literal string, including quotes and escapes; defaults to the 
66
	 * literal for the empty string.
79
	 * literal for the empty string.
Lines 99-104 Link Here
99
				return null;
112
				return null;
100
			}
113
			}
101
		}
114
		}
115
		if (property == CONSTANT_PROPERTY) {
116
			if (get) {
117
				return getConstant();
118
			} else {
119
				return null;
120
			}
121
		}
102
		// allow default implementation to flag the error
122
		// allow default implementation to flag the error
103
		return super.internalGetSetObjectProperty(property, get, value);
123
		return super.internalGetSetObjectProperty(property, get, value);
104
	}
124
	}
Lines 136-141 Link Here
136
		visitor.endVisit(this);
156
		visitor.endVisit(this);
137
	}
157
	}
138
	
158
	
159
	/* (non-Javadoc)
160
	 * @see org.eclipse.jdt.core.dom.Expression#getConstant()
161
	 */
162
	public Object getConstant() {
163
		return this.constant;
164
	}
165
139
	/**
166
	/**
140
	 * Returns the string value of this literal node to the given string
167
	 * Returns the string value of this literal node to the given string
141
	 * literal token. The token is the sequence of characters that would appear
168
	 * literal token. The token is the sequence of characters that would appear
Lines 321-327 Link Here
321
	 * Method declared on ASTNode.
348
	 * Method declared on ASTNode.
322
	 */
349
	 */
323
	int memSize() {
350
	int memSize() {
324
		int size = BASE_NODE_SIZE + 1 * 4 + stringSize(escapedValue);
351
		int size = BASE_NODE_SIZE + 2 * 4 + stringSize(escapedValue);
325
		return size;
352
		return size;
326
	}
353
	}
327
	
354
	
(-)SuperFieldAccess.java (-1 / +35 lines)
Lines 33-38 Link Here
33
public class SuperFieldAccess extends Expression {
33
public class SuperFieldAccess extends Expression {
34
34
35
	/**
35
	/**
36
	 * The "constant" structural property of this node type.
37
	 * @since 3.1
38
	 */
39
	public static final SimplePropertyDescriptor CONSTANT_PROPERTY = 
40
		new SimplePropertyDescriptor(SuperFieldAccess.class, "constant", Object.class, OPTIONAL); //$NON-NLS-1$
41
42
	/**
36
	 * The "qualifier" structural property of this node type.
43
	 * The "qualifier" structural property of this node type.
37
	 * @since 3.0
44
	 * @since 3.0
38
	 */
45
	 */
Lines 58-63 Link Here
58
		createPropertyList(SuperFieldAccess.class, propertyList);
65
		createPropertyList(SuperFieldAccess.class, propertyList);
59
		addProperty(QUALIFIER_PROPERTY, propertyList);
66
		addProperty(QUALIFIER_PROPERTY, propertyList);
60
		addProperty(NAME_PROPERTY, propertyList);
67
		addProperty(NAME_PROPERTY, propertyList);
68
		addProperty(CONSTANT_PROPERTY, propertyList);
61
		PROPERTY_DESCRIPTORS = reapPropertyList(propertyList);
69
		PROPERTY_DESCRIPTORS = reapPropertyList(propertyList);
62
	}
70
	}
63
71
Lines 76-81 Link Here
76
	}
84
	}
77
			
85
			
78
	/**
86
	/**
87
	 * The constant value of this expression if it has one.
88
	 */
89
	Object constant;
90
91
	/**
79
	 * The optional qualifier; <code>null</code> for none; defaults to none.
92
	 * The optional qualifier; <code>null</code> for none; defaults to none.
80
	 */
93
	 */
81
	private Name optionalQualifier = null;
94
	private Name optionalQualifier = null;
Lines 131-136 Link Here
131
		return super.internalGetSetChildProperty(property, get, child);
144
		return super.internalGetSetChildProperty(property, get, child);
132
	}
145
	}
133
	
146
	
147
	/* (non-Javadoc)
148
	 * @see org.eclipse.jdt.core.dom.ASTNode#internalGetSetObjectProperty(org.eclipse.jdt.core.dom.SimplePropertyDescriptor, boolean, java.lang.Object)
149
	 */
150
	Object internalGetSetObjectProperty(SimplePropertyDescriptor property, boolean get, Object value) {
151
		if (property == CONSTANT_PROPERTY) {
152
			if (get) {
153
				return getConstant();
154
			} else {
155
				return null;
156
			}
157
		}
158
		return super.internalGetSetObjectProperty(property, get, value);
159
	}
160
	
134
	/* (omit javadoc for this method)
161
	/* (omit javadoc for this method)
135
	 * Method declared on ASTNode.
162
	 * Method declared on ASTNode.
136
	 */
163
	 */
Lines 170-175 Link Here
170
		visitor.endVisit(this);
197
		visitor.endVisit(this);
171
	}
198
	}
172
	
199
	
200
	/* (non-Javadoc)
201
	 * @see org.eclipse.jdt.core.dom.Expression#getConstant()
202
	 */
203
	public Object getConstant() {
204
		return this.constant;
205
	}
206
173
	/**
207
	/**
174
	 * Returns the qualifier of this "super" field access expression, or 
208
	 * Returns the qualifier of this "super" field access expression, or 
175
	 * <code>null</code> if there is none.
209
	 * <code>null</code> if there is none.
Lines 260-266 Link Here
260
	 */
294
	 */
261
	int memSize() {
295
	int memSize() {
262
		// treat Code as free
296
		// treat Code as free
263
		return BASE_NODE_SIZE + 2 * 4;
297
		return BASE_NODE_SIZE + 3 * 4;
264
	}
298
	}
265
	
299
	
266
	/* (omit javadoc for this method)
300
	/* (omit javadoc for this method)

Return to bug 88548