/******************************************************************************* * Copyright (c) 2000, 2005 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package net.sourceforge.phpdt.core.dom; /** * Abstract base class of AST nodes that represent expressions. * There are several kinds of expressions. *

*

 * Expression:
 *    Name
 *    IntegerLiteral (includes decimal, hex, and octal forms; and long)
 *    FloatingPointLiteral (includes both float and double)
 *    CharacterLiteral
 *    NullLiteral
 *    BooleanLiteral
 *    StringLiteral
 *    TypeLiteral
 *    ThisExpression
 *    SuperFieldAccess
 *    FieldAccess
 *    Assignment
 *    ParenthesizedExpression
 *    ClassInstanceCreation
 *    ArrayCreation
 *    ArrayInitializer
 *    MethodInvocation
 *    SuperMethodInvocation
 *    ArrayAccess
 *    InfixExpression
 *    InstanceofExpression
 *    ConditionalExpression
 *    PostfixExpression
 *    PrefixExpression
 *    CastExpression
 *    VariableDeclarationExpression
 * 
*

* * @since 2.0 */ public abstract class Expression extends ASTNode { /** * Creates a new AST node for an expression owned by the given AST. *

* N.B. This constructor is package-private. *

* * @param ast the AST that is to own this node */ Expression(AST ast) { super(ast); } /** * Resolves and returns the compile-time constant expression value as * specified in JLS2 15.28, if this expression has one. Constant expression * values are unavailable unless bindings are requested when the AST is * being built. 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 expression does not have a compile-time constant expression * value, the result is null. *

* Resolving constant expressions takes into account the value of simple * and qualified names that refer to constant variables (JLS2 4.12.4). *

*

* Note 1: enum constants are not considered constant expressions. * The result is always null for these. *

*

* Note 2: Compile-time constant expressions cannot denote null. * So technically {@link NullLiteral} nodes are not constant expressions. * The result is null for these nonetheless. *

* * @return the constant expression value, or null if this * expression has no constant expression value or if bindings were not * requested when the AST was created * @since 3.1 */ public final Object resolveConstantExpressionValue() { return this.ast.getBindingResolver().resolveConstantExpressionValue(this); } /** * Resolves and returns the binding for the type of this expression. *

* Note that bindings are generally unavailable unless requested when the * AST is being built. *

* * @return the binding for the type of this expression, or * null if the type cannot be resolved */ public final ITypeBinding resolveTypeBinding() { return this.ast.getBindingResolver().resolveExpressionType(this); } /** * Returns whether this expression node is the site of a boxing * conversion (JLS3 5.1.7). This information is available only * when bindings are requested when the AST is being built. * * @return true if this expression is the site of a * boxing conversion, or false if either no boxing conversion * is involved or if bindings were not requested when the AST was created * @since 3.1 */ public final boolean resolveBoxing() { return this.ast.getBindingResolver().resolveBoxing(this); } /** * Returns whether this expression node is the site of an unboxing * conversion (JLS3 5.1.8). This information is available only * when bindings are requested when the AST is being built. * * @return true if this expression is the site of an * unboxing conversion, or false if either no unboxing * conversion is involved or if bindings were not requested when the * AST was created * @since 3.1 */ public final boolean resolveUnboxing() { return this.ast.getBindingResolver().resolveUnboxing(this); } }