Klasse CastExpression

Alle implementierten Schnittstellen:
TypeConstants, TypeIds

public class CastExpression extends Expression
  • Felddetails

    • expression

      public Expression expression
    • type

      public TypeReference type
    • expectedType

      public TypeBinding expectedType
    • instanceofType

      public TypeBinding instanceofType
    • isVarTypeDeclaration

      public boolean isVarTypeDeclaration
  • Konstruktordetails

  • Methodendetails

    • analyseCode

      public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo)
      Setzt außer Kraft:
      analyseCode in Klasse Expression
    • checkNeedForAssignedCast

      public static void checkNeedForAssignedCast(BlockScope scope, TypeBinding expectedType, CastExpression rhs)
      Complain if assigned expression is cast, but not actually used as such, e.g. Object o = (List) object;
    • checkNeedForCastCast

      public static void checkNeedForCastCast(BlockScope scope, CastExpression enclosingCast)
      Complain if cast expression is cast, but not actually needed, int i = (int)(Integer) 12; Note that this (int) cast is however needed: Integer i = 0; char c = (char)((int) i);
    • checkNeedForEnclosingInstanceCast

      public static void checkNeedForEnclosingInstanceCast(BlockScope scope, Expression enclosingInstance, TypeBinding enclosingInstanceType, TypeBinding memberType)
      Casting an enclosing instance will considered as useful if removing it would actually bind to a different type
    • checkNeedForArgumentCast

      public static void checkNeedForArgumentCast(BlockScope scope, int operator, int operatorSignature, Expression expression, int expressionTypeId)
      Only complain for identity cast, since other type of casts may be useful: e.g. ~((~(long) 0) Ungültige Eingabe: "<"Ungültige Eingabe: "<" 32) is different from: ~((~0) Ungültige Eingabe: "<"Ungültige Eingabe: "<" 32)
    • checkNeedForArgumentCasts

      public static void checkNeedForArgumentCasts(BlockScope scope, Expression receiver, TypeBinding receiverType, MethodBinding binding, Expression[] arguments, TypeBinding[] argumentTypes, InvocationSite invocationSite)
      Cast expressions will considered as useful if removing them all would actually bind to a different method (no fine grain analysis on per casted argument basis, simply separate widening cast from narrowing ones)
    • checkNeedForArgumentCasts

      public static void checkNeedForArgumentCasts(BlockScope scope, int operator, int operatorSignature, Expression left, int leftTypeId, boolean leftIsCast, Expression right, int rightTypeId, boolean rightIsCast)
      Check binary operator casted arguments
    • checkNPE

      public boolean checkNPE(BlockScope scope, FlowContext flowContext, FlowInfo flowInfo, int ttlForFieldCheck)
      Beschreibung aus Klasse kopiert: Expression
      Check this expression against potential NPEs, which may occur:
      • if the expression is the receiver in a field access, qualified allocation, array reference or message send incl. implicit message sends like it happens for the collection in a foreach statement.
      • if the expression is subject to unboxing
      • if the expression is the exception in a throw statement
      If a risk of NPE is detected report it to the context. If the expression denotes a local variable, mark it as checked, which affects the flow info.
      Setzt außer Kraft:
      checkNPE in Klasse Expression
      Parameter:
      scope - the scope of the analysis
      flowContext - the current flow context
      flowInfo - the upstream flow info; caveat: may get modified
      ttlForFieldCheck - if this is a reference to a field we will mark that field as nonnull for the specified timeToLive
      Gibt zurück:
      could this expression be checked by the current implementation?
    • checkUnsafeCast

      public boolean checkUnsafeCast(Scope scope, TypeBinding castType, TypeBinding expressionType, TypeBinding match, boolean isNarrowing)
      Setzt außer Kraft:
      checkUnsafeCast in Klasse Expression
    • checkUnsafeCast

      public static boolean checkUnsafeCast(Expression expression, Scope scope, TypeBinding castType, TypeBinding expressionType, TypeBinding match, boolean isNarrowing)
    • generateCode

      public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean valueRequired)
      Cast expression code generation
      Setzt außer Kraft:
      generateCode in Klasse Expression
      Parameter:
      currentScope - org.eclipse.jdt.internal.compiler.lookup.BlockScope
      codeStream - org.eclipse.jdt.internal.compiler.codegen.CodeStream
      valueRequired - boolean
    • innermostCastedExpression

      public Expression innermostCastedExpression()
    • localVariableBinding

      public LocalVariableBinding localVariableBinding()
      Beschreibung aus Klasse kopiert: Expression
      Returns the local variable referenced by this node. Can be a direct reference (SingleNameReference) or thru a cast expression etc...
      Setzt außer Kraft:
      localVariableBinding in Klasse Expression
      Siehe auch:
      • Ungültige Referenz
        org.eclipse.jdt.internal.compiler.ast.Expression#localVariableBinding()
    • nullStatus

      public int nullStatus(FlowInfo flowInfo, FlowContext flowContext)
      Setzt außer Kraft:
      nullStatus in Klasse Expression
    • optimizedBooleanConstant

      public Constant optimizedBooleanConstant()
      Beschreibung aus Klasse kopiert: Expression
      Constant usable for bytecode pattern optimizations, but cannot be inlined since it is not strictly equivalent to the definition of constant expressions. In particular, some side-effects may be required to occur (only the end value is known).
      Setzt außer Kraft:
      optimizedBooleanConstant in Klasse Expression
      Gibt zurück:
      Constant known to be of boolean type
      Siehe auch:
      • Ungültige Referenz
        org.eclipse.jdt.internal.compiler.ast.Expression#optimizedBooleanConstant()
    • printExpression

      public StringBuffer printExpression(int indent, StringBuffer output)
      Angegeben von:
      printExpression in Klasse Expression
    • resolveType

      public TypeBinding resolveType(BlockScope scope)
      Beschreibung aus Klasse kopiert: Expression
      Resolve the type of this expression in the context of a blockScope
      Setzt außer Kraft:
      resolveType in Klasse Expression
      Parameter:
      scope -
      Gibt zurück:
      Return the actual type of this expression after resolution
    • setExpectedType

      public void setExpectedType(TypeBinding expectedType)
      Beschreibung aus Klasse kopiert: Expression
      Record the type expectation before this expression is typechecked. e.g. String s = foo();, foo() will be tagged as being expected of type String Used to trigger proper inference of generic method invocations.
      Setzt außer Kraft:
      setExpectedType in Klasse Expression
      Parameter:
      expectedType - The type denoting an expectation in the context of an assignment conversion
      Siehe auch:
      • Ungültige Referenz
        org.eclipse.jdt.internal.compiler.ast.Expression#setExpectedType(org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TypeBinding)
    • tagAsNeedCheckCast

      public void tagAsNeedCheckCast()
      Setzt außer Kraft:
      tagAsNeedCheckCast in Klasse Expression
      Siehe auch:
      • Ungültige Referenz
        org.eclipse.jdt.internal.compiler.ast.Expression#tagAsNeedCheckCast()
    • tagAsUnnecessaryCast

      public void tagAsUnnecessaryCast(Scope scope, TypeBinding castType)
      Beschreibung aus Klasse kopiert: Expression
      Record the fact a cast expression got detected as being unnecessary.
      Setzt außer Kraft:
      tagAsUnnecessaryCast in Klasse Expression
      Parameter:
      scope -
      castType -
      Siehe auch:
      • Ungültige Referenz
        org.eclipse.jdt.internal.compiler.ast.Expression#tagAsUnnecessaryCast(Scope, TypeBinding)
    • setInstanceofType

      public void setInstanceofType(TypeBinding instanceofTypeBinding)
    • setVarTypeDeclaration

      public void setVarTypeDeclaration(boolean value)
    • traverse

      public void traverse(ASTVisitor visitor, BlockScope blockScope)
      Beschreibung aus Klasse kopiert: Expression
      Traverse an expression in the context of a blockScope
      Setzt außer Kraft:
      traverse in Klasse Expression
      Parameter:
      visitor -
      blockScope -