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 (-3 / +10 lines)
Lines 62-68 Link Here
62
	public static List propertyDescriptors(int apiLevel) {
62
	public static List propertyDescriptors(int apiLevel) {
63
		return PROPERTY_DESCRIPTORS;
63
		return PROPERTY_DESCRIPTORS;
64
	}
64
	}
65
			
65
66
	/**
66
	/**
67
	 * The boolean; defaults to the literal for <code>false</code>.
67
	 * The boolean; defaults to the literal for <code>false</code>.
68
	 */
68
	 */
Lines 102-108 Link Here
102
		// allow default implementation to flag the error
102
		// allow default implementation to flag the error
103
		return super.internalGetSetBooleanProperty(property, get, newValue);
103
		return super.internalGetSetBooleanProperty(property, get, newValue);
104
	}
104
	}
105
	
105
106
	/* (omit javadoc for this method)
106
	/* (omit javadoc for this method)
107
	 * Method declared on ASTNode.
107
	 * Method declared on ASTNode.
108
	 */
108
	 */
Lines 146-152 Link Here
146
	public boolean booleanValue() {
146
	public boolean booleanValue() {
147
		return this.value;
147
		return this.value;
148
	}
148
	}
149
		
149
150
	/* (non-Javadoc)
151
	 * @see org.eclipse.jdt.core.dom.Expression#getConstant()
152
	 */
153
	public Object getConstant() {
154
		return this.value ? Boolean.TRUE : Boolean.FALSE;
155
	}
156
	
150
	/**
157
	/**
151
	 * Sets the boolean value of this boolean literal node.
158
	 * Sets the boolean value of this boolean literal node.
152
	 * 
159
	 * 
(-)CastExpression.java (-1 / +10 lines)
Lines 82-87 Link Here
82
	private Expression expression = null;
82
	private Expression expression = null;
83
83
84
	/**
84
	/**
85
	 * The constant value of this expression if it has one.
86
	 */
87
	Object constant;
88
	
89
	/**
85
	 * Creates a new AST node for a cast expression owned by the given 
90
	 * 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).
91
	 * AST. By default, the type and expression are unspecified (but legal).
87
	 * <p>
92
	 * <p>
Lines 140-145 Link Here
140
		result.setSourceRange(this.getStartPosition(), this.getLength());
145
		result.setSourceRange(this.getStartPosition(), this.getLength());
141
		result.setType((Type) getType().clone(target));
146
		result.setType((Type) getType().clone(target));
142
		result.setExpression((Expression) getExpression().clone(target));
147
		result.setExpression((Expression) getExpression().clone(target));
148
		result.constant = this.constant;
143
		return result;
149
		return result;
144
	}
150
	}
145
151
Lines 203-208 Link Here
203
		postReplaceChild(oldChild, type, TYPE_PROPERTY);
209
		postReplaceChild(oldChild, type, TYPE_PROPERTY);
204
	}
210
	}
205
	
211
	
212
	public Object getConstant() {
213
		return this.constant;
214
	}
206
	/**
215
	/**
207
	 * Returns the expression of this cast expression.
216
	 * Returns the expression of this cast expression.
208
	 * 
217
	 * 
Lines 248-254 Link Here
248
	 */
257
	 */
249
	int memSize() {
258
	int memSize() {
250
		// treat Code as free
259
		// treat Code as free
251
		return BASE_NODE_SIZE + 2 * 4;
260
		return BASE_NODE_SIZE + 3 * 4;
252
	}
261
	}
253
	
262
	
254
	/* (omit javadoc for this method)
263
	/* (omit javadoc for this method)
(-)CharacterLiteral.java (-2 / +14 lines)
Lines 60-66 Link Here
60
	public static List propertyDescriptors(int apiLevel) {
60
	public static List propertyDescriptors(int apiLevel) {
61
		return PROPERTY_DESCRIPTORS;
61
		return PROPERTY_DESCRIPTORS;
62
	}
62
	}
63
			
63
64
	/**
65
	 * The constant value of this expression if it has one.
66
	 */
67
	Object constant;
68
64
	/**
69
	/**
65
	 * The literal string, including quotes and escapes; defaults to the 
70
	 * The literal string, including quotes and escapes; defaults to the 
66
	 * literal for the character 'X'.
71
	 * literal for the character 'X'.
Lines 136-141 Link Here
136
		visitor.endVisit(this);
141
		visitor.endVisit(this);
137
	}
142
	}
138
	
143
	
144
	/* (non-Javadoc)
145
	 * @see org.eclipse.jdt.core.dom.Expression#getConstant()
146
	 */
147
	public Object getConstant() {
148
		return this.constant;
149
	}
150
139
	/**
151
	/**
140
	 * Returns the string value of this literal node. The value is the sequence
152
	 * Returns the string value of this literal node. The value is the sequence
141
	 * of characters that would appear in the source program, including
153
	 * of characters that would appear in the source program, including
Lines 359-365 Link Here
359
	 * Method declared on ASTNode.
371
	 * Method declared on ASTNode.
360
	 */
372
	 */
361
	int memSize() {
373
	int memSize() {
362
		int size = BASE_NODE_SIZE + 1 * 4 + stringSize(escapedValue);
374
		int size = BASE_NODE_SIZE + 2 * 4 + stringSize(escapedValue);
363
		return size;
375
		return size;
364
	}
376
	}
365
	
377
	
(-)ConditionalExpression.java (-4 / +18 lines)
Lines 25-31 Link Here
25
 * @since 2.0
25
 * @since 2.0
26
 */
26
 */
27
public class ConditionalExpression extends Expression {
27
public class ConditionalExpression extends Expression {
28
	
28
29
	/**
29
	/**
30
	 * The "expression" structural property of this node type.
30
	 * The "expression" structural property of this node type.
31
	 * @since 3.0
31
	 * @since 3.0
Lines 77-83 Link Here
77
	public static List propertyDescriptors(int apiLevel) {
77
	public static List propertyDescriptors(int apiLevel) {
78
		return PROPERTY_DESCRIPTORS;
78
		return PROPERTY_DESCRIPTORS;
79
	}
79
	}
80
			
80
	
81
	/**
82
	 * The constant value of this expression if it has one.
83
	 */
84
	Object constant;
85
81
	/**
86
	/**
82
	 * The condition expression; lazily initialized; defaults to an unspecified,
87
	 * The condition expression; lazily initialized; defaults to an unspecified,
83
	 * but legal, expression.
88
	 * but legal, expression.
Lines 148-154 Link Here
148
		// allow default implementation to flag the error
153
		// allow default implementation to flag the error
149
		return super.internalGetSetChildProperty(property, get, child);
154
		return super.internalGetSetChildProperty(property, get, child);
150
	}
155
	}
151
	
156
152
	/* (omit javadoc for this method)
157
	/* (omit javadoc for this method)
153
	 * Method declared on ASTNode.
158
	 * Method declared on ASTNode.
154
	 */
159
	 */
Lines 167-172 Link Here
167
			(Expression) getThenExpression().clone(target));
172
			(Expression) getThenExpression().clone(target));
168
		result.setElseExpression(
173
		result.setElseExpression(
169
			(Expression) getElseExpression().clone(target));
174
			(Expression) getElseExpression().clone(target));
175
		result.constant = this.constant;
170
		return result;
176
		return result;
171
	}
177
	}
172
178
Lines 192-197 Link Here
192
		visitor.endVisit(this);
198
		visitor.endVisit(this);
193
	}
199
	}
194
	
200
	
201
202
	/* (non-Javadoc)
203
	 * @see org.eclipse.jdt.core.dom.Expression#getConstant()
204
	 */
205
	public Object getConstant() {
206
		return this.constant;
207
	}
208
	
195
	/**
209
	/**
196
	 * Returns the condition of this conditional expression.
210
	 * Returns the condition of this conditional expression.
197
	 * 
211
	 * 
Lines 317-323 Link Here
317
	 */
331
	 */
318
	int memSize() {
332
	int memSize() {
319
		// treat Code as free
333
		// treat Code as free
320
		return BASE_NODE_SIZE + 3 * 4;
334
		return BASE_NODE_SIZE + 4 * 4;
321
	}
335
	}
322
	
336
	
323
	/* (omit javadoc for this method)
337
	/* (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 (-3 / +16 lines)
Lines 55-61 Link Here
55
 * @since 2.0
55
 * @since 2.0
56
 */
56
 */
57
public class FieldAccess extends Expression {
57
public class FieldAccess extends Expression {
58
	
58
59
	/**
59
	/**
60
	 * The "expression" structural property of this node type.
60
	 * The "expression" structural property of this node type.
61
	 * @since 3.0
61
	 * @since 3.0
Lines 99-105 Link Here
99
	public static List propertyDescriptors(int apiLevel) {
99
	public static List propertyDescriptors(int apiLevel) {
100
		return PROPERTY_DESCRIPTORS;
100
		return PROPERTY_DESCRIPTORS;
101
	}
101
	}
102
			
102
103
	/**
104
	 * The constant value of this expression if it has one.
105
	 */
106
	Object constant;
107
103
	/**
108
	/**
104
	 * The expression; lazily initialized; defaults to an unspecified,
109
	 * The expression; lazily initialized; defaults to an unspecified,
105
	 * but legal, simple name.
110
	 * but legal, simple name.
Lines 172-177 Link Here
172
		result.setSourceRange(this.getStartPosition(), this.getLength());
177
		result.setSourceRange(this.getStartPosition(), this.getLength());
173
		result.setExpression((Expression) getExpression().clone(target));
178
		result.setExpression((Expression) getExpression().clone(target));
174
		result.setName((SimpleName) getName().clone(target));
179
		result.setName((SimpleName) getName().clone(target));
180
		result.constant = this.constant;
175
		return result;
181
		return result;
176
	}
182
	}
177
183
Lines 196-201 Link Here
196
		visitor.endVisit(this);
202
		visitor.endVisit(this);
197
	}
203
	}
198
	
204
	
205
	/* (non-Javadoc)
206
	 * @see org.eclipse.jdt.core.dom.Expression#getConstant()
207
	 */
208
	public Object getConstant() {
209
		return this.constant;
210
	}
211
199
	/**
212
	/**
200
	 * Returns the expression of this field access expression.
213
	 * Returns the expression of this field access expression.
201
	 * 
214
	 * 
Lines 280-286 Link Here
280
	 */
293
	 */
281
	int memSize() {
294
	int memSize() {
282
		// treat Code as free
295
		// treat Code as free
283
		return BASE_NODE_SIZE + 2 * 4;
296
		return BASE_NODE_SIZE + 3 * 4;
284
	}
297
	}
285
	
298
	
286
	/**
299
	/**
(-)InfixExpression.java (-4 / +17 lines)
Lines 171-177 Link Here
171
		}
171
		}
172
		
172
		
173
	}
173
	}
174
	
174
175
	/**
175
	/**
176
	 * The "leftOperand" structural property of this node type.
176
	 * The "leftOperand" structural property of this node type.
177
	 * @since 3.0
177
	 * @since 3.0
Lines 231-237 Link Here
231
	public static List propertyDescriptors(int apiLevel) {
231
	public static List propertyDescriptors(int apiLevel) {
232
		return PROPERTY_DESCRIPTORS;
232
		return PROPERTY_DESCRIPTORS;
233
	}
233
	}
234
			
234
235
	/**
236
	 * The constant value of this expression if it has one.
237
	 */
238
	Object constant;
239
235
	/**
240
	/**
236
	 * The infix operator; defaults to InfixExpression.Operator.PLUS.
241
	 * The infix operator; defaults to InfixExpression.Operator.PLUS.
237
	 */
242
	 */
Lines 345-350 Link Here
345
			result.extendedOperands().addAll(
350
			result.extendedOperands().addAll(
346
				ASTNode.copySubtrees(target, this.extendedOperands()));
351
				ASTNode.copySubtrees(target, this.extendedOperands()));
347
		}
352
		}
353
		result.constant = this.constant;
348
		return result;
354
		return result;
349
	}
355
	}
350
356
Lines 372-378 Link Here
372
		}
378
		}
373
		visitor.endVisit(this);
379
		visitor.endVisit(this);
374
	}
380
	}
375
	
381
382
	/* (non-Javadoc)
383
	 * @see org.eclipse.jdt.core.dom.Expression#getConstant()
384
	 */
385
	public Object getConstant() {
386
		return this.constant;
387
	}
388
376
	/**
389
	/**
377
	 * Returns the operator of this infix expression.
390
	 * Returns the operator of this infix expression.
378
	 * 
391
	 * 
Lines 521-527 Link Here
521
	 */
534
	 */
522
	int memSize() {
535
	int memSize() {
523
		// treat Operator as free
536
		// treat Operator as free
524
		return BASE_NODE_SIZE + 4 * 4;
537
		return BASE_NODE_SIZE + 5 * 4;
525
	}
538
	}
526
	
539
	
527
	/* (omit javadoc for this method)
540
	/* (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 / +14 lines)
Lines 62-67 Link Here
62
	}
62
	}
63
			
63
			
64
	/**
64
	/**
65
	 * The constant value of this expression if it has one.
66
	 */
67
	Object constant;
68
69
	/**
65
	 * The token string; defaults to the integer literal "0".
70
	 * The token string; defaults to the integer literal "0".
66
	 */
71
	 */
67
	private String tokenValue = "0";//$NON-NLS-1$
72
	private String tokenValue = "0";//$NON-NLS-1$
Lines 116-121 Link Here
116
		NumberLiteral result = new NumberLiteral(target);
121
		NumberLiteral result = new NumberLiteral(target);
117
		result.setSourceRange(this.getStartPosition(), this.getLength());
122
		result.setSourceRange(this.getStartPosition(), this.getLength());
118
		result.setToken(getToken());
123
		result.setToken(getToken());
124
		result.constant = this.constant;
119
		return result;
125
		return result;
120
	}
126
	}
121
127
Lines 134-139 Link Here
134
		visitor.visit(this);
140
		visitor.visit(this);
135
		visitor.endVisit(this);
141
		visitor.endVisit(this);
136
	}
142
	}
143
144
	/* (non-Javadoc)
145
	 * @see org.eclipse.jdt.core.dom.Expression#getConstant()
146
	 */
147
	public Object getConstant() {
148
		return this.constant;
149
	}
137
	
150
	
138
	/**
151
	/**
139
	 * Returns the token of this number literal node. The value is the sequence
152
	 * Returns the token of this number literal node. The value is the sequence
Lines 200-206 Link Here
200
	 * Method declared on ASTNode.
213
	 * Method declared on ASTNode.
201
	 */
214
	 */
202
	int memSize() {
215
	int memSize() {
203
		int size = BASE_NODE_SIZE + 1 * 4 + stringSize(tokenValue);
216
		int size = BASE_NODE_SIZE + 2 * 4 + stringSize(tokenValue);
204
		return size;
217
		return size;
205
	}
218
	}
206
	
219
	
(-)PostfixExpression.java (-2 / +15 lines)
Lines 102-108 Link Here
102
			return (Operator) CODES.get(token);
102
			return (Operator) CODES.get(token);
103
		}
103
		}
104
	}
104
	}
105
	
105
106
	/**
106
	/**
107
	 * The "operator" structural property of this node type.
107
	 * The "operator" structural property of this node type.
108
	 * @since 3.0
108
	 * @since 3.0
Lines 148-153 Link Here
148
	}
148
	}
149
			
149
			
150
	/**
150
	/**
151
	 * The constant value of this expression if it has one.
152
	 */
153
	Object constant;
154
155
	/**
151
	 * The operator; defaults to an unspecified postfix operator.
156
	 * The operator; defaults to an unspecified postfix operator.
152
	 */
157
	 */
153
	private PostfixExpression.Operator operator = 
158
	private PostfixExpression.Operator operator = 
Lines 224-229 Link Here
224
		result.setSourceRange(this.getStartPosition(), this.getLength());
229
		result.setSourceRange(this.getStartPosition(), this.getLength());
225
		result.setOperator(getOperator());
230
		result.setOperator(getOperator());
226
		result.setOperand((Expression) getOperand().clone(target));
231
		result.setOperand((Expression) getOperand().clone(target));
232
		result.constant = this.constant;
227
		return result;
233
		return result;
228
	}
234
	}
229
235
Lines 246-251 Link Here
246
		visitor.endVisit(this);
252
		visitor.endVisit(this);
247
	}
253
	}
248
	
254
	
255
	/* (non-Javadoc)
256
	 * @see org.eclipse.jdt.core.dom.Expression#getConstant()
257
	 */
258
	public Object getConstant() {
259
		return this.constant;
260
	}
261
249
	/**
262
	/**
250
	 * Returns the operator of this postfix expression.
263
	 * Returns the operator of this postfix expression.
251
	 * 
264
	 * 
Lines 315-321 Link Here
315
	 */
328
	 */
316
	int memSize() {
329
	int memSize() {
317
		// treat Operator as free
330
		// treat Operator as free
318
		return BASE_NODE_SIZE + 2 * 4;
331
		return BASE_NODE_SIZE + 3 * 4;
319
	}
332
	}
320
	
333
	
321
	/* (omit javadoc for this method)
334
	/* (omit javadoc for this method)
(-)PrefixExpression.java (-3 / +16 lines)
Lines 118-124 Link Here
118
			return (Operator) CODES.get(token);
118
			return (Operator) CODES.get(token);
119
		}
119
		}
120
	}
120
	}
121
	
121
122
	/**
122
	/**
123
	 * The "operator" structural property of this node type.
123
	 * The "operator" structural property of this node type.
124
	 * @since 3.0
124
	 * @since 3.0
Lines 162-168 Link Here
162
	public static List propertyDescriptors(int apiLevel) {
162
	public static List propertyDescriptors(int apiLevel) {
163
		return PROPERTY_DESCRIPTORS;
163
		return PROPERTY_DESCRIPTORS;
164
	}
164
	}
165
			
165
166
	/**
167
	 * The constant value of this expression if it has one.
168
	 */
169
	Object constant;
170
166
	/**
171
	/**
167
	 * The operator; defaults to an unspecified prefix operator.
172
	 * The operator; defaults to an unspecified prefix operator.
168
	 */
173
	 */
Lines 240-245 Link Here
240
		result.setSourceRange(this.getStartPosition(), this.getLength());
245
		result.setSourceRange(this.getStartPosition(), this.getLength());
241
		result.setOperator(getOperator());
246
		result.setOperator(getOperator());
242
		result.setOperand((Expression) getOperand().clone(target));
247
		result.setOperand((Expression) getOperand().clone(target));
248
		result.constant = this.constant;
243
		return result;
249
		return result;
244
	}
250
	}
245
251
Lines 263-268 Link Here
263
		visitor.endVisit(this);
269
		visitor.endVisit(this);
264
	}
270
	}
265
	
271
	
272
	/* (non-Javadoc)
273
	 * @see org.eclipse.jdt.core.dom.Expression#getConstant()
274
	 */
275
	public Object getConstant() {
276
		return this.constant;
277
	}
278
266
	/**
279
	/**
267
	 * Returns the operator of this prefix expression.
280
	 * Returns the operator of this prefix expression.
268
	 * 
281
	 * 
Lines 332-338 Link Here
332
	 */
345
	 */
333
	int memSize() {
346
	int memSize() {
334
		// treat Operator as free
347
		// treat Operator as free
335
		return BASE_NODE_SIZE + 2 * 4;
348
		return BASE_NODE_SIZE + 3 * 4;
336
	}
349
	}
337
	
350
	
338
	/* (omit javadoc for this method)
351
	/* (omit javadoc for this method)
(-)QualifiedName.java (-1 / +2 lines)
Lines 32-38 Link Here
32
 * @since 2.0
32
 * @since 2.0
33
 */
33
 */
34
public class QualifiedName extends Name {
34
public class QualifiedName extends Name {
35
	
35
36
	/**
36
	/**
37
	 * The "qualifier" structural property of this node type.
37
	 * The "qualifier" structural property of this node type.
38
	 * @since 3.0
38
	 * @since 3.0
Lines 148-153 Link Here
148
		result.setSourceRange(this.getStartPosition(), this.getLength());
148
		result.setSourceRange(this.getStartPosition(), this.getLength());
149
		result.setQualifier((Name) getQualifier().clone(target));
149
		result.setQualifier((Name) getQualifier().clone(target));
150
		result.setName((SimpleName) getName().clone(target));
150
		result.setName((SimpleName) getName().clone(target));
151
		result.constant = this.constant;
151
		return result;
152
		return result;
152
	}
153
	}
153
154
(-)SimpleName.java (+1 lines)
Lines 129-134 Link Here
129
		SimpleName result = new SimpleName(target);
129
		SimpleName result = new SimpleName(target);
130
		result.setSourceRange(this.getStartPosition(), this.getLength());
130
		result.setSourceRange(this.getStartPosition(), this.getLength());
131
		result.setIdentifier(getIdentifier());
131
		result.setIdentifier(getIdentifier());
132
		result.constant = this.constant;
132
		return result;
133
		return result;
133
	}
134
	}
134
	
135
	
(-)StringLiteral.java (-2 / +15 lines)
Lines 60-66 Link Here
60
	public static List propertyDescriptors(int apiLevel) {
60
	public static List propertyDescriptors(int apiLevel) {
61
		return PROPERTY_DESCRIPTORS;
61
		return PROPERTY_DESCRIPTORS;
62
	}
62
	}
63
			
63
64
	/**
65
	 * The constant value of this expression if it has one.
66
	 */
67
	Object constant;
68
64
	/**
69
	/**
65
	 * The literal string, including quotes and escapes; defaults to the 
70
	 * The literal string, including quotes and escapes; defaults to the 
66
	 * literal for the empty string.
71
	 * literal for the empty string.
Lines 117-122 Link Here
117
		StringLiteral result = new StringLiteral(target);
122
		StringLiteral result = new StringLiteral(target);
118
		result.setSourceRange(this.getStartPosition(), this.getLength());
123
		result.setSourceRange(this.getStartPosition(), this.getLength());
119
		result.setEscapedValue(getEscapedValue());
124
		result.setEscapedValue(getEscapedValue());
125
		result.constant = this.constant;
120
		return result;
126
		return result;
121
	}
127
	}
122
128
Lines 136-141 Link Here
136
		visitor.endVisit(this);
142
		visitor.endVisit(this);
137
	}
143
	}
138
	
144
	
145
	/* (non-Javadoc)
146
	 * @see org.eclipse.jdt.core.dom.Expression#getConstant()
147
	 */
148
	public Object getConstant() {
149
		return this.constant;
150
	}
151
139
	/**
152
	/**
140
	 * Returns the string value of this literal node to the given string
153
	 * 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
154
	 * literal token. The token is the sequence of characters that would appear
Lines 321-327 Link Here
321
	 * Method declared on ASTNode.
334
	 * Method declared on ASTNode.
322
	 */
335
	 */
323
	int memSize() {
336
	int memSize() {
324
		int size = BASE_NODE_SIZE + 1 * 4 + stringSize(escapedValue);
337
		int size = BASE_NODE_SIZE + 2 * 4 + stringSize(escapedValue);
325
		return size;
338
		return size;
326
	}
339
	}
327
	
340
	
(-)SuperFieldAccess.java (-1 / +14 lines)
Lines 76-81 Link Here
76
	}
76
	}
77
			
77
			
78
	/**
78
	/**
79
	 * The constant value of this expression if it has one.
80
	 */
81
	Object constant;
82
83
	/**
79
	 * The optional qualifier; <code>null</code> for none; defaults to none.
84
	 * The optional qualifier; <code>null</code> for none; defaults to none.
80
	 */
85
	 */
81
	private Name optionalQualifier = null;
86
	private Name optionalQualifier = null;
Lines 146-151 Link Here
146
		result.setSourceRange(this.getStartPosition(), this.getLength());
151
		result.setSourceRange(this.getStartPosition(), this.getLength());
147
		result.setName((SimpleName) ASTNode.copySubtree(target, getName()));
152
		result.setName((SimpleName) ASTNode.copySubtree(target, getName()));
148
		result.setQualifier((Name) ASTNode.copySubtree(target, getQualifier()));
153
		result.setQualifier((Name) ASTNode.copySubtree(target, getQualifier()));
154
		result.constant = this.constant;
149
		return result;
155
		return result;
150
	}
156
	}
151
157
Lines 170-175 Link Here
170
		visitor.endVisit(this);
176
		visitor.endVisit(this);
171
	}
177
	}
172
	
178
	
179
	/* (non-Javadoc)
180
	 * @see org.eclipse.jdt.core.dom.Expression#getConstant()
181
	 */
182
	public Object getConstant() {
183
		return this.constant;
184
	}
185
173
	/**
186
	/**
174
	 * Returns the qualifier of this "super" field access expression, or 
187
	 * Returns the qualifier of this "super" field access expression, or 
175
	 * <code>null</code> if there is none.
188
	 * <code>null</code> if there is none.
Lines 260-266 Link Here
260
	 */
273
	 */
261
	int memSize() {
274
	int memSize() {
262
		// treat Code as free
275
		// treat Code as free
263
		return BASE_NODE_SIZE + 2 * 4;
276
		return BASE_NODE_SIZE + 3 * 4;
264
	}
277
	}
265
	
278
	
266
	/* (omit javadoc for this method)
279
	/* (omit javadoc for this method)

Return to bug 88548