Class SingleNameReference

All Implemented Interfaces:
OperatorIds, InvocationSite, TypeConstants, TypeIds
Direct Known Subclasses:
CodeSnippetSingleNameReference, CompletionOnKeyword3, CompletionOnSingleNameReference, JavadocSingleNameReference, SelectionOnSingleNameReference

public class SingleNameReference extends NameReference implements OperatorIds
  • Field Details

  • Constructor Details

    • SingleNameReference

      public SingleNameReference(char[] source, long pos)
  • Method Details

    • analyseAssignment

      public FlowInfo analyseAssignment(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo, Assignment assignment, boolean isCompound)
      Specified by:
      analyseAssignment in class Reference
    • analyseCode

      public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo)
      Overrides:
      analyseCode in class Reference
    • analyseCode

      public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo, boolean valueRequired)
      Description copied from class: Expression
      More sophisticated for of the flow analysis used for analyzing expressions, and be able to optimize out portions of expressions where no actual value is required.
      Overrides:
      analyseCode in class Expression
      Returns:
      The state of initialization after the analysis of the current expression
    • checkFieldAccess

      public TypeBinding checkFieldAccess(BlockScope scope)
    • checkNPE

      public boolean checkNPE(BlockScope scope, FlowContext flowContext, FlowInfo flowInfo, int ttlForFieldCheck)
      Description copied from class: 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.
      Overrides:
      checkNPE in class Reference
      Parameters:
      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
      Returns:
      could this expression be checked by the current implementation?
    • computeConversion

      public void computeConversion(Scope scope, TypeBinding runtimeTimeType, TypeBinding compileTimeType)
      Description copied from class: Expression
      Base types need that the widening is explicitly done by the compiler using some bytecode like i2f. Also check unsafe type operations.
      Overrides:
      computeConversion in class Expression
      See Also:
      • invalid reference
        org.eclipse.jdt.internal.compiler.ast.Expression#computeConversion(org.aspectj.org.eclipse.jdt.internal.compiler.lookup.Scope, org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TypeBinding, org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TypeBinding)
    • generateAssignment

      public void generateAssignment(BlockScope currentScope, CodeStream codeStream, Assignment assignment, boolean valueRequired)
      Specified by:
      generateAssignment in class Reference
    • generateCode

      public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean valueRequired)
      Description copied from class: Expression
      Every expression is responsible for generating its implicit conversion when necessary.
      Overrides:
      generateCode in class Expression
      Parameters:
      currentScope - org.eclipse.jdt.internal.compiler.lookup.BlockScope
      codeStream - org.eclipse.jdt.internal.compiler.codegen.CodeStream
      valueRequired - boolean
    • generateCompoundAssignment

      public void generateCompoundAssignment(BlockScope currentScope, CodeStream codeStream, Expression expression, int operator, int assignmentImplicitConversion, boolean valueRequired)
      Specified by:
      generateCompoundAssignment in class Reference
    • generateCompoundAssignment

      public void generateCompoundAssignment(BlockScope currentScope, CodeStream codeStream, MethodBinding writeAccessor, Expression expression, int operator, int assignmentImplicitConversion, boolean valueRequired)
    • generatePostIncrement

      public void generatePostIncrement(BlockScope currentScope, CodeStream codeStream, CompoundAssignment postIncrement, boolean valueRequired)
      Specified by:
      generatePostIncrement in class Reference
    • generateReceiver

      public void generateReceiver(CodeStream codeStream)
    • genericTypeArguments

      public TypeBinding[] genericTypeArguments()
      Specified by:
      genericTypeArguments in interface InvocationSite
      See Also:
      • invalid reference
        org.eclipse.jdt.internal.compiler.lookup.InvocationSite#genericTypeArguments()
    • isEquivalent

      public boolean isEquivalent(Reference reference)
      Description copied from class: Reference
      Is the given reference equivalent to the receiver, meaning that both denote the same path of field reads? Used from FlowContext.isNullcheckedFieldAccess(Reference).
      Overrides:
      isEquivalent in class Reference
    • localVariableBinding

      public LocalVariableBinding localVariableBinding()
      Returns the local variable referenced by this node. Can be a direct reference (SingleNameReference) or thru a cast expression etc...
      Overrides:
      localVariableBinding in class Expression
    • nullAnnotatedVariableBinding

      public VariableBinding nullAnnotatedVariableBinding(boolean supportTypeAnnotations)
      Description copied from class: Expression
      Used on the lhs of an assignment for detecting null spec violation. If this expression represents a null-annotated variable return the variable binding, otherwise null.
      Overrides:
      nullAnnotatedVariableBinding in class Expression
      Parameters:
      supportTypeAnnotations - if true this causes any variable binding to be used independent of declaration annotations (for in-depth analysis of type annotations)
    • nullStatus

      public int nullStatus(FlowInfo flowInfo, FlowContext flowContext)
      Overrides:
      nullStatus in class Reference
    • manageEnclosingInstanceAccessIfNecessary

      public void manageEnclosingInstanceAccessIfNecessary(BlockScope currentScope, FlowInfo flowInfo)
    • manageSyntheticAccessIfNecessary

      public void manageSyntheticAccessIfNecessary(BlockScope currentScope, FlowInfo flowInfo, boolean isReadAccess)
    • postConversionType

      public TypeBinding postConversionType(Scope scope)
      Description copied from class: Expression
      Returns the type of the expression after required implicit conversions. When expression type gets promoted or inserted a generic cast, the converted type will differ from the resolved type (surface side-effects from #computeConversion(...)).
      Overrides:
      postConversionType in class Expression
      Returns:
      the type after implicit conversion
      See Also:
      • invalid reference
        org.eclipse.jdt.internal.compiler.ast.Expression#postConversionType(Scope)
    • printExpression

      public StringBuilder printExpression(int indent, StringBuilder output)
      Specified by:
      printExpression in class Expression
    • reportError

      public TypeBinding reportError(BlockScope scope)
    • resolveType

      public TypeBinding resolveType(BlockScope scope)
      Description copied from class: Expression
      Resolve the type of this expression in the context of a blockScope
      Overrides:
      resolveType in class Expression
      Returns:
      Return the actual type of this expression after resolution
    • traverse

      public void traverse(ASTVisitor visitor, BlockScope scope)
      Description copied from class: Expression
      Traverse an expression in the context of a blockScope
      Overrides:
      traverse in class Expression
    • traverse

      public void traverse(ASTVisitor visitor, ClassScope scope)
      Description copied from class: Expression
      Traverse an expression in the context of a classScope
      Overrides:
      traverse in class Expression
    • unboundReferenceErrorName

      public String unboundReferenceErrorName()
      Specified by:
      unboundReferenceErrorName in class NameReference
    • getName

      public char[][] getName()
      Specified by:
      getName in class NameReference