Index: ASTConverter.java
===================================================================
RCS file: /home/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTConverter.java,v
retrieving revision 1.201
diff -u -r1.201 ASTConverter.java
--- ASTConverter.java 17 Mar 2005 05:16:24 -0000 1.201
+++ ASTConverter.java 21 Mar 2005 21:16:06 -0000
@@ -44,9 +44,11 @@
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.compiler.env.IConstants;
import org.eclipse.jdt.internal.compiler.env.IGenericType;
+import org.eclipse.jdt.internal.compiler.impl.Constant;
import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
import org.eclipse.jdt.internal.compiler.lookup.CompilerModifiers;
import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
+import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
import org.eclipse.jdt.internal.compiler.parser.Scanner;
import org.eclipse.jdt.internal.compiler.parser.TerminalTokens;
@@ -886,6 +888,11 @@
if (this.resolveBindings) {
this.recordNodes(infixExpression, expression);
}
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=88548
+ final Constant constant = expression.constant;
+ if (constant != null && constant != Constant.NotAConstant) {
+ infixExpression.constant = convert(constant);
+ }
int expressionOperatorID = (expression.bits & org.eclipse.jdt.internal.compiler.ast.ASTNode.OperatorMASK) >> org.eclipse.jdt.internal.compiler.ast.ASTNode.OperatorSHIFT;
switch (expressionOperatorID) {
@@ -1088,6 +1095,11 @@
if (this.resolveBindings) {
recordNodes(castExpression, expression);
}
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=88548
+ final Constant constant = expression.constant;
+ if (constant != null && constant != Constant.NotAConstant) {
+ castExpression.constant = convert(constant);
+ }
return castExpression;
}
@@ -1103,6 +1115,11 @@
literal.setEscapedValue(new String(tokens));
literal.setSourceRange(sourceStart, length);
removeLeadingAndTrailingCommentsFromLiteral(literal);
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=88548
+ final Constant constant = expression.constant;
+ if (constant != null && constant != Constant.NotAConstant) {
+ literal.constant = convert(constant);
+ }
return literal;
}
public Expression convert(org.eclipse.jdt.internal.compiler.ast.ClassLiteralAccess expression) {
@@ -1234,6 +1251,11 @@
conditionalExpression.setExpression(convert(expression.condition));
conditionalExpression.setThenExpression(convert(expression.valueIfTrue));
conditionalExpression.setElseExpression(convert(expression.valueIfFalse));
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=88548
+ final Constant constant = expression.constant;
+ if (constant != null && constant != Constant.NotAConstant) {
+ conditionalExpression.constant = convert(constant);
+ }
return conditionalExpression;
}
@@ -1248,6 +1270,21 @@
retrieveSemiColonPosition(continueStatement);
return continueStatement;
}
+
+ private Object convert(Constant constant) {
+ switch (constant.typeID()) {
+ case TypeIds.T_int : return new Integer(constant.intValue());
+ case TypeIds.T_byte : return new Byte(constant.byteValue());
+ case TypeIds.T_short : return new Short(constant.shortValue());
+ case TypeIds.T_char : return new Character(constant.charValue());
+ case TypeIds.T_float : return new Float(constant.floatValue());
+ case TypeIds.T_double : return new Double(constant.doubleValue());
+ case TypeIds.T_boolean : return constant.booleanValue() ? Boolean.TRUE : Boolean.FALSE;
+ case TypeIds.T_long : return new Long(constant.longValue());
+ case TypeIds.T_JavaLangString : return constant.stringValue();
+ }
+ return null;
+ }
public DoStatement convert(org.eclipse.jdt.internal.compiler.ast.DoStatement statement) {
DoStatement doStatement = this.ast.newDoStatement();
@@ -1269,6 +1306,11 @@
}
literal.setSourceRange(sourceStart, length);
removeLeadingAndTrailingCommentsFromLiteral(literal);
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=88548
+ final Constant constant = expression.constant;
+ if (constant != null && constant != Constant.NotAConstant) {
+ literal.constant = convert(constant);
+ }
return literal;
}
@@ -1330,6 +1372,11 @@
if (this.resolveBindings) {
recordNodes(infixExpression, expression);
}
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=88548
+ final Constant constant = expression.constant;
+ if (constant != null && constant != Constant.NotAConstant) {
+ infixExpression.constant = convert(expression.constant);
+ }
Expression leftExpression = convert(expression.left);
infixExpression.setLeftOperand(leftExpression);
infixExpression.setRightOperand(convert(expression.right));
@@ -1567,6 +1614,11 @@
recordNodes(simpleName, reference);
}
superFieldAccess.setSourceRange(reference.receiver.sourceStart, reference.sourceEnd - reference.receiver.sourceStart + 1);
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=88548
+ final Constant constant = reference.constant;
+ if (constant != null && constant != Constant.NotAConstant) {
+ superFieldAccess.constant = convert(constant);
+ }
return superFieldAccess;
} else {
FieldAccess fieldAccess = this.ast.newFieldAccess();
@@ -1584,6 +1636,11 @@
recordNodes(simpleName, reference);
}
fieldAccess.setSourceRange(receiver.getStartPosition(), reference.sourceEnd - receiver.getStartPosition() + 1);
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=88548
+ final Constant constant = reference.constant;
+ if (constant != null && constant != Constant.NotAConstant) {
+ fieldAccess.constant = convert(constant);
+ }
return fieldAccess;
}
}
@@ -1599,6 +1656,11 @@
}
literal.setSourceRange(sourceStart, length);
removeLeadingAndTrailingCommentsFromLiteral(literal);
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=88548
+ final Constant constant = expression.constant;
+ if (constant != null && constant != Constant.NotAConstant) {
+ literal.constant = convert(constant);
+ }
return literal;
}
@@ -1699,6 +1761,11 @@
}
literal.setSourceRange(sourceStart, length);
removeLeadingAndTrailingCommentsFromLiteral(literal);
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=88548
+ final Constant constant = expression.constant;
+ if (constant != null && constant != Constant.NotAConstant) {
+ literal.constant = convert(constant);
+ }
return literal;
}
@@ -1713,6 +1780,11 @@
}
literal.setSourceRange(sourceStart, length);
removeLeadingAndTrailingCommentsFromLiteral(literal);
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=88548
+ final Constant constant = expression.constant;
+ if (constant != null && constant != Constant.NotAConstant) {
+ literal.constant = convert(constant);
+ }
return literal;
}
@@ -1761,6 +1833,11 @@
}
literal.setSourceRange(sourceStart, length);
removeLeadingAndTrailingCommentsFromLiteral(literal);
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=88548
+ final Constant constant = expression.constant;
+ if (constant != null && constant != Constant.NotAConstant) {
+ literal.constant = convert(constant);
+ }
return literal;
}
@@ -1775,6 +1852,11 @@
}
literal.setSourceRange(sourceStart, length);
removeLeadingAndTrailingCommentsFromLiteral(literal);
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=88548
+ final Constant constant = expression.constant;
+ if (constant != null && constant != Constant.NotAConstant) {
+ literal.constant = convert(constant);
+ }
return literal;
}
@@ -1948,6 +2030,11 @@
this.recordNodes(infixExpression, expression);
}
infixExpression.setSourceRange(expression.sourceStart, expression.sourceEnd - expression.sourceStart + 1);
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=88548
+ final Constant constant = expression.constant;
+ if (constant != null && constant != Constant.NotAConstant) {
+ infixExpression.constant = convert(constant);
+ }
return infixExpression;
}
@@ -2088,7 +2175,13 @@
}
public Name convert(org.eclipse.jdt.internal.compiler.ast.QualifiedNameReference nameReference) {
- return setQualifiedNameNameAndSourceRanges(nameReference.tokens, nameReference.sourcePositions, nameReference);
+ Name name = setQualifiedNameNameAndSourceRanges(nameReference.tokens, nameReference.sourcePositions, nameReference);
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=88548
+ final Constant constant = nameReference.constant;
+ if (constant != null && constant != Constant.NotAConstant) {
+ name.constant = convert(constant);
+ }
+ return name;
}
public Name convert(org.eclipse.jdt.internal.compiler.ast.QualifiedSuperReference reference) {
@@ -2151,6 +2244,11 @@
recordNodes(name, nameReference);
}
name.setSourceRange(nameReference.sourceStart, nameReference.sourceEnd - nameReference.sourceStart + 1);
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=88548
+ final Constant constant = nameReference.constant;
+ if (constant != null && constant != Constant.NotAConstant) {
+ name.constant = convert(constant);
+ }
return name;
}
@@ -2284,6 +2382,11 @@
}
literal.setEscapedValue(new String(tokens));
literal.setSourceRange(expression.sourceStart, expression.sourceEnd - expression.sourceStart + 1);
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=88548
+ final Constant constant = expression.constant;
+ if (constant != null && constant != Constant.NotAConstant) {
+ literal.constant = convert(constant);
+ }
return literal;
}
@@ -2518,6 +2621,11 @@
break;
case org.eclipse.jdt.internal.compiler.ast.OperatorIds.TWIDDLE :
prefixExpression.setOperator(PrefixExpression.Operator.COMPLEMENT);
+ }
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=88548
+ final Constant constant = expression.constant;
+ if (constant != null && constant != Constant.NotAConstant) {
+ prefixExpression.constant = convert(constant);
}
return prefixExpression;
}
Index: BooleanLiteral.java
===================================================================
RCS file: /home/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/BooleanLiteral.java,v
retrieving revision 1.16
diff -u -r1.16 BooleanLiteral.java
--- BooleanLiteral.java 23 Feb 2005 02:47:27 -0000 1.16
+++ BooleanLiteral.java 21 Mar 2005 21:16:07 -0000
@@ -35,6 +35,13 @@
new SimplePropertyDescriptor(BooleanLiteral.class, "booleanValue", boolean.class, MANDATORY); //$NON-NLS-1$
/**
+ * The "constant" structural property of this node type.
+ * @since 3.1
+ */
+ public static final SimplePropertyDescriptor CONSTANT_PROPERTY =
+ new SimplePropertyDescriptor(BooleanLiteral.class, "constant", Object.class, OPTIONAL); //$NON-NLS-1$
+
+ /**
* A list of property descriptors (element type:
* {@link StructuralPropertyDescriptor}),
* or null if uninitialized.
@@ -45,6 +52,7 @@
List properyList = new ArrayList(2);
createPropertyList(BooleanLiteral.class, properyList);
addProperty(BOOLEAN_VALUE_PROPERTY, properyList);
+ addProperty(CONSTANT_PROPERTY, properyList);
PROPERTY_DESCRIPTORS = reapPropertyList(properyList);
}
@@ -62,7 +70,7 @@
public static List propertyDescriptors(int apiLevel) {
return PROPERTY_DESCRIPTORS;
}
-
+
/**
* The boolean; defaults to the literal for false
.
*/
@@ -103,6 +111,21 @@
return super.internalGetSetBooleanProperty(property, get, newValue);
}
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.core.dom.ASTNode#internalGetSetObjectProperty(org.eclipse.jdt.core.dom.SimplePropertyDescriptor, boolean, java.lang.Object)
+ */
+ Object internalGetSetObjectProperty(SimplePropertyDescriptor property, boolean get, Object newValue) {
+ if (property == CONSTANT_PROPERTY) {
+ if (get) {
+ return getConstant();
+ } else {
+ preValueChange(CONSTANT_PROPERTY);
+ postValueChange(CONSTANT_PROPERTY);
+ return null;
+ }
+ }
+ return super.internalGetSetObjectProperty(property, get, newValue);
+ }
/* (omit javadoc for this method)
* Method declared on ASTNode.
*/
@@ -146,7 +169,14 @@
public boolean booleanValue() {
return this.value;
}
-
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.core.dom.Expression#getConstant()
+ */
+ public Object getConstant() {
+ return this.value ? Boolean.TRUE : Boolean.FALSE;
+ }
+
/**
* Sets the boolean value of this boolean literal node.
*
Index: CastExpression.java
===================================================================
RCS file: /home/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/CastExpression.java,v
retrieving revision 1.21
diff -u -r1.21 CastExpression.java
--- CastExpression.java 23 Feb 2005 02:47:27 -0000 1.21
+++ CastExpression.java 21 Mar 2005 21:16:07 -0000
@@ -41,6 +41,13 @@
new ChildPropertyDescriptor(CastExpression.class, "expression", Expression.class, MANDATORY, CYCLE_RISK); //$NON-NLS-1$
/**
+ * The "constant" structural property of this node type.
+ * @since 3.1
+ */
+ public static final SimplePropertyDescriptor CONSTANT_PROPERTY =
+ new SimplePropertyDescriptor(CastExpression.class, "constant", Object.class, OPTIONAL); //$NON-NLS-1$
+
+ /**
* A list of property descriptors (element type:
* {@link StructuralPropertyDescriptor}),
* or null if uninitialized.
@@ -52,6 +59,7 @@
createPropertyList(CastExpression.class, properyList);
addProperty(TYPE_PROPERTY, properyList);
addProperty(EXPRESSION_PROPERTY, properyList);
+ addProperty(CONSTANT_PROPERTY, properyList);
PROPERTY_DESCRIPTORS = reapPropertyList(properyList);
}
@@ -82,6 +90,11 @@
private Expression expression = null;
/**
+ * The constant value of this expression if it has one.
+ */
+ Object constant;
+
+ /**
* Creates a new AST node for a cast expression owned by the given
* AST. By default, the type and expression are unspecified (but legal).
*
@@ -124,7 +137,22 @@
// allow default implementation to flag the error
return super.internalGetSetChildProperty(property, get, child);
}
-
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.core.dom.ASTNode#internalGetSetObjectProperty(org.eclipse.jdt.core.dom.SimplePropertyDescriptor, boolean, java.lang.Object)
+ */
+ Object internalGetSetObjectProperty(SimplePropertyDescriptor property, boolean get, Object value) {
+ if (property == CONSTANT_PROPERTY) {
+ if (get) {
+ return getConstant();
+ } else {
+ preValueChange(CONSTANT_PROPERTY);
+ postValueChange(CONSTANT_PROPERTY);
+ return null;
+ }
+ }
+ return super.internalGetSetObjectProperty(property, get, value);
+ }
/* (omit javadoc for this method)
* Method declared on ASTNode.
*/
@@ -203,6 +231,9 @@
postReplaceChild(oldChild, type, TYPE_PROPERTY);
}
+ public Object getConstant() {
+ return this.constant;
+ }
/**
* Returns the expression of this cast expression.
*
@@ -248,7 +279,7 @@
*/
int memSize() {
// treat Code as free
- return BASE_NODE_SIZE + 2 * 4;
+ return BASE_NODE_SIZE + 3 * 4;
}
/* (omit javadoc for this method)
Index: CharacterLiteral.java
===================================================================
RCS file: /home/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/CharacterLiteral.java,v
retrieving revision 1.30
diff -u -r1.30 CharacterLiteral.java
--- CharacterLiteral.java 23 Feb 2005 02:47:27 -0000 1.30
+++ CharacterLiteral.java 21 Mar 2005 21:16:07 -0000
@@ -26,6 +26,13 @@
public class CharacterLiteral extends Expression {
/**
+ * The "constant" structural property of this node type.
+ * @since 3.1
+ */
+ public static final SimplePropertyDescriptor CONSTANT_PROPERTY =
+ new SimplePropertyDescriptor(CharacterLiteral.class, "constant", Object.class, OPTIONAL); //$NON-NLS-1$
+
+ /**
* The "escapedValue" structural property of this node type.
* @since 3.0
*/
@@ -43,6 +50,7 @@
List properyList = new ArrayList(2);
createPropertyList(CharacterLiteral.class, properyList);
addProperty(ESCAPED_VALUE_PROPERTY, properyList);
+ addProperty(CONSTANT_PROPERTY, properyList);
PROPERTY_DESCRIPTORS = reapPropertyList(properyList);
}
@@ -60,7 +68,12 @@
public static List propertyDescriptors(int apiLevel) {
return PROPERTY_DESCRIPTORS;
}
-
+
+ /**
+ * The constant value of this expression if it has one.
+ */
+ Object constant;
+
/**
* The literal string, including quotes and escapes; defaults to the
* literal for the character 'X'.
@@ -99,6 +112,15 @@
return null;
}
}
+ if (property == CONSTANT_PROPERTY) {
+ if (get) {
+ return getConstant();
+ } else {
+ preValueChange(CONSTANT_PROPERTY);
+ postValueChange(CONSTANT_PROPERTY);
+ return null;
+ }
+ }
// allow default implementation to flag the error
return super.internalGetSetObjectProperty(property, get, value);
}
@@ -136,6 +158,13 @@
visitor.endVisit(this);
}
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.core.dom.Expression#getConstant()
+ */
+ public Object getConstant() {
+ return this.constant;
+ }
+
/**
* Returns the string value of this literal node. The value is the sequence
* of characters that would appear in the source program, including
@@ -359,7 +388,7 @@
* Method declared on ASTNode.
*/
int memSize() {
- int size = BASE_NODE_SIZE + 1 * 4 + stringSize(escapedValue);
+ int size = BASE_NODE_SIZE + 2 * 4 + stringSize(escapedValue);
return size;
}
Index: ConditionalExpression.java
===================================================================
RCS file: /home/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ConditionalExpression.java,v
retrieving revision 1.21
diff -u -r1.21 ConditionalExpression.java
--- ConditionalExpression.java 23 Feb 2005 02:47:27 -0000 1.21
+++ ConditionalExpression.java 21 Mar 2005 21:16:07 -0000
@@ -27,6 +27,13 @@
public class ConditionalExpression extends Expression {
/**
+ * The "constant" structural property of this node type.
+ * @since 3.1
+ */
+ public static final SimplePropertyDescriptor CONSTANT_PROPERTY =
+ new SimplePropertyDescriptor(ConditionalExpression.class, "constant", Object.class, OPTIONAL); //$NON-NLS-1$
+
+ /**
* The "expression" structural property of this node type.
* @since 3.0
*/
@@ -60,6 +67,7 @@
addProperty(EXPRESSION_PROPERTY, properyList);
addProperty(THEN_EXPRESSION_PROPERTY, properyList);
addProperty(ELSE_EXPRESSION_PROPERTY, properyList);
+ addProperty(CONSTANT_PROPERTY, properyList);
PROPERTY_DESCRIPTORS = reapPropertyList(properyList);
}
@@ -77,7 +85,12 @@
public static List propertyDescriptors(int apiLevel) {
return PROPERTY_DESCRIPTORS;
}
-
+
+ /**
+ * The constant value of this expression if it has one.
+ */
+ Object constant;
+
/**
* The condition expression; lazily initialized; defaults to an unspecified,
* but legal, expression.
@@ -148,7 +161,23 @@
// allow default implementation to flag the error
return super.internalGetSetChildProperty(property, get, child);
}
-
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.core.dom.ASTNode#internalGetSetObjectProperty(org.eclipse.jdt.core.dom.SimplePropertyDescriptor, boolean, java.lang.Object)
+ */
+ Object internalGetSetObjectProperty(SimplePropertyDescriptor property, boolean get, Object value) {
+ if (property == CONSTANT_PROPERTY) {
+ if (get) {
+ return getConstant();
+ } else {
+ preValueChange(CONSTANT_PROPERTY);
+ postValueChange(CONSTANT_PROPERTY);
+ return null;
+ }
+ }
+ return super.internalGetSetObjectProperty(property, get, value);
+ }
+
/* (omit javadoc for this method)
* Method declared on ASTNode.
*/
@@ -192,6 +221,14 @@
visitor.endVisit(this);
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.core.dom.Expression#getConstant()
+ */
+ public Object getConstant() {
+ return this.constant;
+ }
+
/**
* Returns the condition of this conditional expression.
*
@@ -317,7 +354,7 @@
*/
int memSize() {
// treat Code as free
- return BASE_NODE_SIZE + 3 * 4;
+ return BASE_NODE_SIZE + 4 * 4;
}
/* (omit javadoc for this method)
Index: Expression.java
===================================================================
RCS file: /home/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Expression.java,v
retrieving revision 1.8
diff -u -r1.8 Expression.java
--- Expression.java 23 Feb 2005 02:47:27 -0000 1.8
+++ Expression.java 21 Mar 2005 21:16:07 -0000
@@ -63,6 +63,23 @@
}
/**
+ * Returns this expression's constant value if it has one.
+ * Some expressions may have a value computed at compile-time. If the type of
+ * the value is a primitive type, the result is the boxed equivalent (i.e.,
+ * int returned as an Integer
). If the type of the value is
+ * String
, the result is the string itself. If the variable has
+ * no compile-time computed value, the result is null
.
+ * (Note: compile-time constant expressions cannot denote null
;
+ * JLS2 15.28.). The result is always null
for enum constants.
+ *
+ * @return the constant value, or null
if none
+ * @since 3.1
+ */
+ public Object getConstant() {
+ return null;
+ }
+
+ /**
* Resolves and returns the binding for the type of this expression.
*
* Note that bindings are generally unavailable unless requested when the
Index: FieldAccess.java
===================================================================
RCS file: /home/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/FieldAccess.java,v
retrieving revision 1.26
diff -u -r1.26 FieldAccess.java
--- FieldAccess.java 23 Feb 2005 02:47:27 -0000 1.26
+++ FieldAccess.java 21 Mar 2005 21:16:07 -0000
@@ -57,6 +57,13 @@
public class FieldAccess extends Expression {
/**
+ * The "constant" structural property of this node type.
+ * @since 3.1
+ */
+ public static final SimplePropertyDescriptor CONSTANT_PROPERTY =
+ new SimplePropertyDescriptor(FieldAccess.class, "constant", Object.class, OPTIONAL); //$NON-NLS-1$
+
+ /**
* The "expression" structural property of this node type.
* @since 3.0
*/
@@ -82,6 +89,7 @@
createPropertyList(FieldAccess.class, properyList);
addProperty(EXPRESSION_PROPERTY, properyList);
addProperty(NAME_PROPERTY, properyList);
+ addProperty(CONSTANT_PROPERTY, properyList);
PROPERTY_DESCRIPTORS = reapPropertyList(properyList);
}
@@ -99,7 +107,12 @@
public static List propertyDescriptors(int apiLevel) {
return PROPERTY_DESCRIPTORS;
}
-
+
+ /**
+ * The constant value of this expression if it has one.
+ */
+ Object constant;
+
/**
* The expression; lazily initialized; defaults to an unspecified,
* but legal, simple name.
@@ -160,6 +173,23 @@
/* (omit javadoc for this method)
* Method declared on ASTNode.
*/
+ Object internalGetSetObjectProperty(SimplePropertyDescriptor property, boolean get, Object value) {
+ if (property == CONSTANT_PROPERTY) {
+ if (get) {
+ return getConstant();
+ } else {
+ preValueChange(CONSTANT_PROPERTY);
+ postValueChange(CONSTANT_PROPERTY);
+ return null;
+ }
+ }
+ // allow default implementation to flag the error
+ return super.internalGetSetObjectProperty(property, get, value);
+ }
+
+ /* (omit javadoc for this method)
+ * Method declared on ASTNode.
+ */
final int getNodeType0() {
return FIELD_ACCESS;
}
@@ -196,6 +226,13 @@
visitor.endVisit(this);
}
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.core.dom.Expression#getConstant()
+ */
+ public Object getConstant() {
+ return this.constant;
+ }
+
/**
* Returns the expression of this field access expression.
*
@@ -280,7 +317,7 @@
*/
int memSize() {
// treat Code as free
- return BASE_NODE_SIZE + 2 * 4;
+ return BASE_NODE_SIZE + 3 * 4;
}
/**
Index: InfixExpression.java
===================================================================
RCS file: /home/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/InfixExpression.java,v
retrieving revision 1.27
diff -u -r1.27 InfixExpression.java
--- InfixExpression.java 23 Feb 2005 02:47:27 -0000 1.27
+++ InfixExpression.java 21 Mar 2005 21:16:07 -0000
@@ -173,6 +173,13 @@
}
/**
+ * The "constant" structural property of this node type.
+ * @since 3.1
+ */
+ public static final SimplePropertyDescriptor CONSTANT_PROPERTY =
+ new SimplePropertyDescriptor(InfixExpression.class, "constant", Object.class, OPTIONAL); //$NON-NLS-1$
+
+ /**
* The "leftOperand" structural property of this node type.
* @since 3.0
*/
@@ -214,6 +221,7 @@
addProperty(OPERATOR_PROPERTY, properyList);
addProperty(RIGHT_OPERAND_PROPERTY, properyList);
addProperty(EXTENDED_OPERANDS_PROPERTY, properyList);
+ addProperty(CONSTANT_PROPERTY, properyList);
PROPERTY_DESCRIPTORS = reapPropertyList(properyList);
}
@@ -231,7 +239,12 @@
public static List propertyDescriptors(int apiLevel) {
return PROPERTY_DESCRIPTORS;
}
-
+
+ /**
+ * The constant value of this expression if it has one.
+ */
+ Object constant;
+
/**
* The infix operator; defaults to InfixExpression.Operator.PLUS.
*/
@@ -285,6 +298,15 @@
return null;
}
}
+ if (property == CONSTANT_PROPERTY) {
+ if (get) {
+ return getConstant();
+ } else {
+ preValueChange(CONSTANT_PROPERTY);
+ postValueChange(CONSTANT_PROPERTY);
+ return null;
+ }
+ }
// allow default implementation to flag the error
return super.internalGetSetObjectProperty(property, get, value);
}
@@ -372,7 +394,14 @@
}
visitor.endVisit(this);
}
-
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.core.dom.Expression#getConstant()
+ */
+ public Object getConstant() {
+ return this.constant;
+ }
+
/**
* Returns the operator of this infix expression.
*
@@ -521,7 +550,7 @@
*/
int memSize() {
// treat Operator as free
- return BASE_NODE_SIZE + 4 * 4;
+ return BASE_NODE_SIZE + 5 * 4;
}
/* (omit javadoc for this method)
Index: Name.java
===================================================================
RCS file: /home/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Name.java,v
retrieving revision 1.13
diff -u -r1.13 Name.java
--- Name.java 23 Feb 2005 02:47:27 -0000 1.13
+++ Name.java 21 Mar 2005 21:16:07 -0000
@@ -31,9 +31,14 @@
* Approximate base size of an expression node instance in bytes,
* including object header and instance fields.
*/
- static final int BASE_NAME_NODE_SIZE = BASE_NODE_SIZE + 1 * 4;
+ static final int BASE_NAME_NODE_SIZE = BASE_NODE_SIZE + 2 * 4;
/**
+ * The constant value of this expression if it has one.
+ */
+ Object constant;
+
+ /**
* This index represents the position inside a qualified name.
*/
int index;
@@ -50,6 +55,13 @@
super(ast);
}
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.core.dom.Expression#getConstant()
+ */
+ public Object getConstant() {
+ return this.constant;
+ }
+
/**
* Returns whether this name is a simple name
* (SimpleName
).
Index: NumberLiteral.java
===================================================================
RCS file: /home/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/NumberLiteral.java,v
retrieving revision 1.28
diff -u -r1.28 NumberLiteral.java
--- NumberLiteral.java 23 Feb 2005 02:47:27 -0000 1.28
+++ NumberLiteral.java 21 Mar 2005 21:16:07 -0000
@@ -26,6 +26,13 @@
public class NumberLiteral extends Expression {
/**
+ * The "constant" structural property of this node type.
+ * @since 3.1
+ */
+ public static final SimplePropertyDescriptor CONSTANT_PROPERTY =
+ new SimplePropertyDescriptor(NumberLiteral.class, "constant", Object.class, OPTIONAL); //$NON-NLS-1$
+
+ /**
* The "token" structural property of this node type.
* @since 3.0
*/
@@ -43,6 +50,7 @@
List propertyList = new ArrayList(2);
createPropertyList(NumberLiteral.class, propertyList);
addProperty(TOKEN_PROPERTY, propertyList);
+ addProperty(CONSTANT_PROPERTY, propertyList);
PROPERTY_DESCRIPTORS = reapPropertyList(propertyList);
}
@@ -62,6 +70,11 @@
}
/**
+ * The constant value of this expression if it has one.
+ */
+ Object constant;
+
+ /**
* The token string; defaults to the integer literal "0".
*/
private String tokenValue = "0";//$NON-NLS-1$
@@ -98,6 +111,15 @@
return null;
}
}
+ if (property == CONSTANT_PROPERTY) {
+ if (get) {
+ return getConstant();
+ } else {
+ preValueChange(CONSTANT_PROPERTY);
+ postValueChange(CONSTANT_PROPERTY);
+ return null;
+ }
+ }
// allow default implementation to flag the error
return super.internalGetSetObjectProperty(property, get, value);
}
@@ -134,6 +156,13 @@
visitor.visit(this);
visitor.endVisit(this);
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.core.dom.Expression#getConstant()
+ */
+ public Object getConstant() {
+ return this.constant;
+ }
/**
* Returns the token of this number literal node. The value is the sequence
@@ -200,7 +229,7 @@
* Method declared on ASTNode.
*/
int memSize() {
- int size = BASE_NODE_SIZE + 1 * 4 + stringSize(tokenValue);
+ int size = BASE_NODE_SIZE + 2 * 4 + stringSize(tokenValue);
return size;
}
Index: PrefixExpression.java
===================================================================
RCS file: /home/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/PrefixExpression.java,v
retrieving revision 1.23
diff -u -r1.23 PrefixExpression.java
--- PrefixExpression.java 23 Feb 2005 02:47:27 -0000 1.23
+++ PrefixExpression.java 21 Mar 2005 21:16:08 -0000
@@ -120,6 +120,14 @@
}
/**
+ * The "constant" structural property of this node type.
+ * @since 3.1
+ */
+ public static final SimplePropertyDescriptor CONSTANT_PROPERTY =
+ new SimplePropertyDescriptor(PrefixExpression.class, "constant", Object.class, OPTIONAL); //$NON-NLS-1$
+
+
+ /**
* The "operator" structural property of this node type.
* @since 3.0
*/
@@ -145,6 +153,7 @@
createPropertyList(PrefixExpression.class, propertyList);
addProperty(OPERATOR_PROPERTY, propertyList);
addProperty(OPERAND_PROPERTY, propertyList);
+ addProperty(CONSTANT_PROPERTY, propertyList);
PROPERTY_DESCRIPTORS = reapPropertyList(propertyList);
}
@@ -162,7 +171,12 @@
public static List propertyDescriptors(int apiLevel) {
return PROPERTY_DESCRIPTORS;
}
-
+
+ /**
+ * The constant value of this expression if it has one.
+ */
+ Object constant;
+
/**
* The operator; defaults to an unspecified prefix operator.
*/
@@ -205,6 +219,15 @@
return null;
}
}
+ if (property == CONSTANT_PROPERTY) {
+ if (get) {
+ return getConstant();
+ } else {
+ preValueChange(CONSTANT_PROPERTY);
+ postValueChange(CONSTANT_PROPERTY);
+ return null;
+ }
+ }
// allow default implementation to flag the error
return super.internalGetSetObjectProperty(property, get, value);
}
@@ -263,6 +286,13 @@
visitor.endVisit(this);
}
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.core.dom.Expression#getConstant()
+ */
+ public Object getConstant() {
+ return this.constant;
+ }
+
/**
* Returns the operator of this prefix expression.
*
@@ -332,7 +362,7 @@
*/
int memSize() {
// treat Operator as free
- return BASE_NODE_SIZE + 2 * 4;
+ return BASE_NODE_SIZE + 3 * 4;
}
/* (omit javadoc for this method)
Index: QualifiedName.java
===================================================================
RCS file: /home/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/QualifiedName.java,v
retrieving revision 1.35
diff -u -r1.35 QualifiedName.java
--- QualifiedName.java 23 Feb 2005 02:47:27 -0000 1.35
+++ QualifiedName.java 21 Mar 2005 21:16:08 -0000
@@ -34,6 +34,13 @@
public class QualifiedName extends Name {
/**
+ * The "constant" structural property of this node type.
+ * @since 3.1
+ */
+ public static final SimplePropertyDescriptor CONSTANT_PROPERTY =
+ new SimplePropertyDescriptor(QualifiedName.class, "constant", Object.class, OPTIONAL); //$NON-NLS-1$
+
+ /**
* The "qualifier" structural property of this node type.
* @since 3.0
*/
@@ -59,6 +66,7 @@
createPropertyList(QualifiedName.class, propertyList);
addProperty(QUALIFIER_PROPERTY, propertyList);
addProperty(NAME_PROPERTY, propertyList);
+ addProperty(CONSTANT_PROPERTY, propertyList);
PROPERTY_DESCRIPTORS = reapPropertyList(propertyList);
}
@@ -131,6 +139,22 @@
}
// allow default implementation to flag the error
return super.internalGetSetChildProperty(property, get, child);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.core.dom.ASTNode#internalGetSetObjectProperty(org.eclipse.jdt.core.dom.SimplePropertyDescriptor, boolean, java.lang.Object)
+ */
+ Object internalGetSetObjectProperty(SimplePropertyDescriptor property, boolean get, Object value) {
+ if (property == CONSTANT_PROPERTY) {
+ if (get) {
+ return getConstant();
+ } else {
+ preValueChange(CONSTANT_PROPERTY);
+ postValueChange(CONSTANT_PROPERTY);
+ return null;
+ }
+ }
+ return super.internalGetSetObjectProperty(property, get, value);
}
/* (omit javadoc for this method)
Index: SimpleName.java
===================================================================
RCS file: /home/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SimpleName.java,v
retrieving revision 1.40
diff -u -r1.40 SimpleName.java
--- SimpleName.java 12 Mar 2005 16:36:47 -0000 1.40
+++ SimpleName.java 21 Mar 2005 21:16:08 -0000
@@ -31,6 +31,13 @@
public class SimpleName extends Name {
/**
+ * The "constant" structural property of this node type.
+ * @since 3.1
+ */
+ public static final SimplePropertyDescriptor CONSTANT_PROPERTY =
+ new SimplePropertyDescriptor(SimpleName.class, "constant", Object.class, OPTIONAL); //$NON-NLS-1$
+
+ /**
* The "identifier" structural property of this node type.
*
* @since 3.0
@@ -50,6 +57,7 @@
List propertyList = new ArrayList(2);
createPropertyList(SimpleName.class, propertyList);
addProperty(IDENTIFIER_PROPERTY, propertyList);
+ addProperty(CONSTANT_PROPERTY, propertyList);
PROPERTY_DESCRIPTORS = reapPropertyList(propertyList);
}
@@ -108,6 +116,15 @@
return getIdentifier();
} else {
setIdentifier((String) value);
+ return null;
+ }
+ }
+ if (property == CONSTANT_PROPERTY) {
+ if (get) {
+ return getConstant();
+ } else {
+ preValueChange(CONSTANT_PROPERTY);
+ postValueChange(CONSTANT_PROPERTY);
return null;
}
}
Index: StringLiteral.java
===================================================================
RCS file: /home/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/StringLiteral.java,v
retrieving revision 1.32
diff -u -r1.32 StringLiteral.java
--- StringLiteral.java 23 Feb 2005 02:47:27 -0000 1.32
+++ StringLiteral.java 21 Mar 2005 21:16:08 -0000
@@ -26,6 +26,13 @@
public class StringLiteral extends Expression {
/**
+ * The "constant" structural property of this node type.
+ * @since 3.1
+ */
+ public static final SimplePropertyDescriptor CONSTANT_PROPERTY =
+ new SimplePropertyDescriptor(StringLiteral.class, "constant", Object.class, OPTIONAL); //$NON-NLS-1$
+
+ /**
* The "escapedValue" structural property of this node type.
* @since 3.0
*/
@@ -43,6 +50,7 @@
List propertyList = new ArrayList(2);
createPropertyList(StringLiteral.class, propertyList);
addProperty(ESCAPED_VALUE_PROPERTY, propertyList);
+ addProperty(CONSTANT_PROPERTY, propertyList);
PROPERTY_DESCRIPTORS = reapPropertyList(propertyList);
}
@@ -60,7 +68,12 @@
public static List propertyDescriptors(int apiLevel) {
return PROPERTY_DESCRIPTORS;
}
-
+
+ /**
+ * The constant value of this expression if it has one.
+ */
+ Object constant;
+
/**
* The literal string, including quotes and escapes; defaults to the
* literal for the empty string.
@@ -99,6 +112,15 @@
return null;
}
}
+ if (property == CONSTANT_PROPERTY) {
+ if (get) {
+ return getConstant();
+ } else {
+ preValueChange(CONSTANT_PROPERTY);
+ postValueChange(CONSTANT_PROPERTY);
+ return null;
+ }
+ }
// allow default implementation to flag the error
return super.internalGetSetObjectProperty(property, get, value);
}
@@ -136,6 +158,13 @@
visitor.endVisit(this);
}
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.core.dom.Expression#getConstant()
+ */
+ public Object getConstant() {
+ return this.constant;
+ }
+
/**
* Returns the string value of this literal node to the given string
* literal token. The token is the sequence of characters that would appear
@@ -321,7 +350,7 @@
* Method declared on ASTNode.
*/
int memSize() {
- int size = BASE_NODE_SIZE + 1 * 4 + stringSize(escapedValue);
+ int size = BASE_NODE_SIZE + 2 * 4 + stringSize(escapedValue);
return size;
}
Index: SuperFieldAccess.java
===================================================================
RCS file: /home/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SuperFieldAccess.java,v
retrieving revision 1.24
diff -u -r1.24 SuperFieldAccess.java
--- SuperFieldAccess.java 23 Feb 2005 02:47:27 -0000 1.24
+++ SuperFieldAccess.java 21 Mar 2005 21:16:08 -0000
@@ -33,6 +33,13 @@
public class SuperFieldAccess extends Expression {
/**
+ * The "constant" structural property of this node type.
+ * @since 3.1
+ */
+ public static final SimplePropertyDescriptor CONSTANT_PROPERTY =
+ new SimplePropertyDescriptor(SuperFieldAccess.class, "constant", Object.class, OPTIONAL); //$NON-NLS-1$
+
+ /**
* The "qualifier" structural property of this node type.
* @since 3.0
*/
@@ -58,6 +65,7 @@
createPropertyList(SuperFieldAccess.class, propertyList);
addProperty(QUALIFIER_PROPERTY, propertyList);
addProperty(NAME_PROPERTY, propertyList);
+ addProperty(CONSTANT_PROPERTY, propertyList);
PROPERTY_DESCRIPTORS = reapPropertyList(propertyList);
}
@@ -76,6 +84,11 @@
}
/**
+ * The constant value of this expression if it has one.
+ */
+ Object constant;
+
+ /**
* The optional qualifier; null
for none; defaults to none.
*/
private Name optionalQualifier = null;
@@ -131,6 +144,22 @@
return super.internalGetSetChildProperty(property, get, child);
}
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.core.dom.ASTNode#internalGetSetObjectProperty(org.eclipse.jdt.core.dom.SimplePropertyDescriptor, boolean, java.lang.Object)
+ */
+ Object internalGetSetObjectProperty(SimplePropertyDescriptor property, boolean get, Object value) {
+ if (property == CONSTANT_PROPERTY) {
+ if (get) {
+ return getConstant();
+ } else {
+ preValueChange(CONSTANT_PROPERTY);
+ postValueChange(CONSTANT_PROPERTY);
+ return null;
+ }
+ }
+ return super.internalGetSetObjectProperty(property, get, value);
+ }
+
/* (omit javadoc for this method)
* Method declared on ASTNode.
*/
@@ -170,6 +199,13 @@
visitor.endVisit(this);
}
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.core.dom.Expression#getConstant()
+ */
+ public Object getConstant() {
+ return this.constant;
+ }
+
/**
* Returns the qualifier of this "super" field access expression, or
* null
if there is none.
@@ -260,7 +296,7 @@
*/
int memSize() {
// treat Code as free
- return BASE_NODE_SIZE + 2 * 4;
+ return BASE_NODE_SIZE + 3 * 4;
}
/* (omit javadoc for this method)