Package org.jtool.cfg

Class JReference

java.lang.Object
org.jtool.cfg.JReference
Direct Known Subclasses:
JMethodReference, JVariableReference

public abstract class JReference extends Object
An abstract class that represents a reference to a field, a local variable, or a method.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final org.eclipse.jdt.core.dom.ASTNode
    The AST node corresponding to this reference.
    protected CodeRange
    The code range information of the AST node for this reference.
    protected String
    The name of a class that declares the referenced element.
    protected String
    The name of a method that declares the referenced element.
    protected String
    The name of a class that encloses the referencing element.
    protected String
    The name of a method that encloses the referencing element.
    protected QualifiedName
    The fully-qualified name of the referenced name.
    protected boolean
    A flag that indicates whether the referenced element exists inside the target project.
    protected boolean
    A flag that indicates whether the type of the referenced element is primitive.
    protected int
    The modifier information of the referenced element.
    protected String
    The referenced name without its attributes.
    protected String
    The form of this reference, e.g., a, x.b or y.m()
    protected String
    The type of the referenced element.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    JReference(org.eclipse.jdt.core.dom.ASTNode node)
    Creates a new object that represents a reference.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    boolean
    Tests if a given reference is equal to this reference.
    static org.eclipse.jdt.core.dom.ITypeBinding
    findEnclosingClass(org.eclipse.jdt.core.dom.ASTNode node)
    Finds a class enclosing a given AST node.
    protected static String
    findEnclosingClassName(org.eclipse.jdt.core.dom.ASTNode node)
    Obtains the qualified name of a class enclosing a given AST node.
    static org.eclipse.jdt.core.dom.IMethodBinding
    findEnclosingMethod(org.eclipse.jdt.core.dom.ASTNode node)
    Finds a method enclosing a given AST node.
    protected static String
    findEnclosingMethodName(org.eclipse.jdt.core.dom.ASTNode node)
    Obtains the qualified name of a method enclosing a given AST node.
    org.eclipse.jdt.core.dom.ASTNode
    Returns the AST node corresponding to this reference.
    Obtains the code range information of the AST node for this reference.
    Returns the name of a class that declares the referenced element.
    Returns the name of a method that declares the referenced element.
    Returns the name of a class that encloses the referencing element.
    static org.eclipse.jdt.core.dom.ASTNode
    getEnclosingElement(org.eclipse.jdt.core.dom.ASTNode node, int sort)
    Finds an ancestor of a given AST node, having a specified sort.
    Returns the name of a method that encloses the referencing element.
    int
    Returns the modifiers of the referenced element
    Returns the name of the referenced element without its attributes.
    protected static String
    getParameterString(org.eclipse.jdt.core.dom.IMethodBinding mbinding)
    Obtains the string that represents parameters of a method having a given method binding information.
    protected static String
    getQualifiedClassName(org.eclipse.jdt.core.dom.ITypeBinding tbinding)
    Returns the qualified name of a class related to a given type binding information.
    protected static String
    getQualifiedMethodName(org.eclipse.jdt.core.dom.IMethodBinding mbinding)
    Returns the qualified name of a method related to a given method binding information.
    Returns the fully-qualified name of the referenced element.
    Returns the receiver name of the referenced element.
    Returns the reference name of the referenced element.
    Returns the signature of the referenced element.
    protected static String
    getSignature(org.eclipse.jdt.core.dom.IMethodBinding mbinding)
    Returns the signature of a method related to a given method binding information.
    int
    Returns the position that indicates where the code fragment for this reference begins.
    Returns the type of the referenced element.
    protected String
    getType(org.eclipse.jdt.core.dom.ITypeBinding tbinding)
    Returns the string representing type.
    int
    boolean
    Tests if this is a reference to an alias variable.
    boolean
    Tests if this reference is available.
    protected static boolean
    isConstructor(org.eclipse.jdt.core.dom.IMethodBinding mbinding)
    Tests a given method binding indicates a reference to a constructor.
    boolean
    Tests if this is a reference to an element that has the default visibility.
    protected static boolean
    isEnumConstant(org.eclipse.jdt.core.dom.IVariableBinding vbinding)
    Tests if a given method binding indicates a reference to an enum contant.
    protected static boolean
    isField(org.eclipse.jdt.core.dom.IVariableBinding vbinding)
    Tests if a given method binding indicates a reference to a field.
    boolean
    Tests if this is a reference to a field.
    boolean
    Tests if this is a reference to an element inside the target project.
    protected static boolean
    isLocal(org.eclipse.jdt.core.dom.IVariableBinding vbinding)
    Tests if a given method binding indicates a reference to a local variable.
    boolean
    Tests if this is a reference to a local variable.
    protected static boolean
    isMethod(org.eclipse.jdt.core.dom.IMethodBinding mbinding)
    Tests if a given method binding indicates a reference to a method.
    boolean
    Tests if this is a reference to a method.
    boolean
    Tests if the type of the referenced element is primitive.
    boolean
    Tests if this is a reference to an element that has the private visibility.
    boolean
    Tests if this is a reference to an element that has the protected visibility.
    boolean
    Tests if this is a reference to an element that has the public visibility.
    boolean
    Tests if this is a reference to the return value.
    boolean
    Tests if this is a reference to a field, which is uncovered in a called method.
    boolean
    Tests if this is a reference to an unsupported program element.
    boolean
    Tests if this is a reference to a variable.
    boolean
    Tests if this is a reference to one of various kind of program elements.
    boolean
    Tests if the type of the referenced element is void.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • astNode

      protected final org.eclipse.jdt.core.dom.ASTNode astNode
      The AST node corresponding to this reference.
    • enclosingClassName

      protected String enclosingClassName
      The name of a class that encloses the referencing element.
    • enclosingMethodName

      protected String enclosingMethodName
      The name of a method that encloses the referencing element.
    • declaringClassName

      protected String declaringClassName
      The name of a class that declares the referenced element.
    • declaringMethodName

      protected String declaringMethodName
      The name of a method that declares the referenced element.
    • fqn

      protected QualifiedName fqn
      The fully-qualified name of the referenced name.
    • name

      protected String name
      The referenced name without its attributes.
    • referenceForm

      protected String referenceForm
      The form of this reference, e.g., a, x.b or y.m()
    • type

      protected String type
      The type of the referenced element.
    • isPrimitiveType

      protected boolean isPrimitiveType
      A flag that indicates whether the type of the referenced element is primitive.
    • modifiers

      protected int modifiers
      The modifier information of the referenced element.
    • inProject

      protected boolean inProject
      A flag that indicates whether the referenced element exists inside the target project.
    • codeRange

      protected CodeRange codeRange
      The code range information of the AST node for this reference.
  • Constructor Details

    • JReference

      protected JReference(org.eclipse.jdt.core.dom.ASTNode node)
      Creates a new object that represents a reference. This constructor is not intended to be invoked by clients.
      Parameters:
      node - AST node corresponding to this reference
  • Method Details

    • getASTNode

      public org.eclipse.jdt.core.dom.ASTNode getASTNode()
      Returns the AST node corresponding to this reference.
      Returns:
      the AST node
    • getEnclosingClassName

      public String getEnclosingClassName()
      Returns the name of a class that encloses the referencing element.
      Returns:
      the class name for the referencing element
    • getEnclosingMethodName

      public String getEnclosingMethodName()
      Returns the name of a method that encloses the referencing element.
      Returns:
      the method name for the referencing element
    • getDeclaringClassName

      public String getDeclaringClassName()
      Returns the name of a class that declares the referenced element.
      Returns:
      the class name for the referenced element
    • getDeclaringMethodName

      public String getDeclaringMethodName()
      Returns the name of a method that declares the referenced element.
      Returns:
      the method name for the referenced element
    • getName

      public String getName()
      Returns the name of the referenced element without its attributes.
      Returns:
      the name
    • getSignature

      public String getSignature()
      Returns the signature of the referenced element.
      Returns:
      the signature
    • getQualifiedName

      public QualifiedName getQualifiedName()
      Returns the fully-qualified name of the referenced element.
      Returns:
      the fully-qualified name
    • getReferenceForm

      public String getReferenceForm()
      Returns the reference name of the referenced element.
      Returns:
      the reference name
    • getReceiverName

      public String getReceiverName()
      Returns the receiver name of the referenced element.
      Returns:
      the receiver name, or the empty string if the element does not have any receiver
    • getType

      public String getType()
      Returns the type of the referenced element.
      Returns:
      the type name
    • isPrimitiveType

      public boolean isPrimitiveType()
      Tests if the type of the referenced element is primitive.
      Returns:
      true if the primitive type, otherwise false
    • isVoidType

      public boolean isVoidType()
      Tests if the type of the referenced element is void.
      Returns:
      true if the void type, otherwise false
    • getModifiers

      public int getModifiers()
      Returns the modifiers of the referenced element
      Returns:
      the modifier information
    • isPublic

      public boolean isPublic()
      Tests if this is a reference to an element that has the public visibility.
      Returns:
      true if this refers to an element having the public visibility, otherwise false
    • isProtected

      public boolean isProtected()
      Tests if this is a reference to an element that has the protected visibility.
      Returns:
      true if this refers to an element having the protected visibility, otherwise false
    • isDefault

      public boolean isDefault()
      Tests if this is a reference to an element that has the default visibility.
      Returns:
      true if this refers to an element having the default visibility, otherwise false
    • isPrivate

      public boolean isPrivate()
      Tests if this is a reference to an element that has the private visibility.
      Returns:
      true if this refers to an element having the private visibility, otherwise false
    • isInProject

      public boolean isInProject()
      Tests if this is a reference to an element inside the target project.
      Returns:
      true if this is a reference to the inside element, otherwise false
    • isFieldAccess

      public boolean isFieldAccess()
      Tests if this is a reference to a field.
      Returns:
      true if this is a field reference, otherwise false
    • isLocalAccess

      public boolean isLocalAccess()
      Tests if this is a reference to a local variable.
      Returns:
      true if this is a local variable reference, otherwise false
    • isVariableAccess

      public boolean isVariableAccess()
      Tests if this is a reference to a variable.
      Returns:
      true if this is a variable reference, otherwise false
    • isMethodCall

      public boolean isMethodCall()
      Tests if this is a reference to a method.
      Returns:
      true if this is a method reference, otherwise false
    • isReturnValueReference

      public boolean isReturnValueReference()
      Tests if this is a reference to the return value.
      Returns:
      true if this is a return value reference, otherwise false
    • isUncoveredFieldReference

      public boolean isUncoveredFieldReference()
      Tests if this is a reference to a field, which is uncovered in a called method.
      Returns:
      true if this is an uncovered field reference, otherwise false
    • isAliasReference

      public boolean isAliasReference()
      Tests if this is a reference to an alias variable.
      Returns:
      true if this is an alias reference, otherwise false
    • isVersatileReference

      public boolean isVersatileReference()
      Tests if this is a reference to one of various kind of program elements.
      Returns:
      true if this is a versatile reference, otherwise false
    • isUnsupportedReference

      public boolean isUnsupportedReference()
      Tests if this is a reference to an unsupported program element.
      Returns:
      true if this is an unsupported reference, otherwise false
    • isAvailable

      public boolean isAvailable()
      Tests if this reference is available.
      Returns:
      true if this is a reference to an available element, otherwise false
    • getCodeRange

      public CodeRange getCodeRange()
      Obtains the code range information of the AST node for this reference.
      Returns:
      the code range of this reference
    • getStartPosition

      public int getStartPosition()
      Returns the position that indicates where the code fragment for this reference begins.
      Returns:
      the index value of the position on the source code
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • equals

      public boolean equals(JReference jvar)
      Tests if a given reference is equal to this reference.
      Parameters:
      jvar - the reference to be checked
      Returns:
      the true if the given reference is equal to this reference
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • isField

      protected static boolean isField(org.eclipse.jdt.core.dom.IVariableBinding vbinding)
      Tests if a given method binding indicates a reference to a field.
      Parameters:
      vbinding - the variable biding information to be checked
      Returns:
      true if the method binding indicates a reference to a field, otherwise false
    • isEnumConstant

      protected static boolean isEnumConstant(org.eclipse.jdt.core.dom.IVariableBinding vbinding)
      Tests if a given method binding indicates a reference to an enum contant.
      Parameters:
      vbinding - the variable biding information to be checked
      Returns:
      true if the method binding indicates a reference to an enum contant, otherwise false
    • isLocal

      protected static boolean isLocal(org.eclipse.jdt.core.dom.IVariableBinding vbinding)
      Tests if a given method binding indicates a reference to a local variable.
      Parameters:
      vbinding - the variable biding information to be checked
      Returns:
      true if the method binding indicates a reference to a local variable, otherwise false
    • isMethod

      protected static boolean isMethod(org.eclipse.jdt.core.dom.IMethodBinding mbinding)
      Tests if a given method binding indicates a reference to a method.
      Parameters:
      mbinding - the method binding information to be checked
      Returns:
      true if the method binding indicates a reference to a method, otherwise false
    • isConstructor

      protected static boolean isConstructor(org.eclipse.jdt.core.dom.IMethodBinding mbinding)
      Tests a given method binding indicates a reference to a constructor.
      Parameters:
      mbinding - the method binding information to be checked
      Returns:
      true if the method binding indicates a reference to a constructor, otherwise false
    • findEnclosingClassName

      protected static String findEnclosingClassName(org.eclipse.jdt.core.dom.ASTNode node)
      Obtains the qualified name of a class enclosing a given AST node.
      Parameters:
      node - the node of interest
      Returns:
      the qualified name, or the empty string if no class is found
    • findEnclosingMethodName

      protected static String findEnclosingMethodName(org.eclipse.jdt.core.dom.ASTNode node)
      Obtains the qualified name of a method enclosing a given AST node.
      Parameters:
      node - the node of interest
      Returns:
      the qualified name, or the empty string if no method is found
    • getQualifiedClassName

      protected static String getQualifiedClassName(org.eclipse.jdt.core.dom.ITypeBinding tbinding)
      Returns the qualified name of a class related to a given type binding information.
      Parameters:
      tbinding - the type biding information on the class
      Returns:
      the qualified name, or the empty string if no class is found
    • getQualifiedMethodName

      protected static String getQualifiedMethodName(org.eclipse.jdt.core.dom.IMethodBinding mbinding)
      Returns the qualified name of a method related to a given method binding information.
      Parameters:
      mbinding - the method binding information on the method
      Returns:
      the qualified name, or the empty string if no method is found
    • getSignature

      protected static String getSignature(org.eclipse.jdt.core.dom.IMethodBinding mbinding)
      Returns the signature of a method related to a given method binding information.
      Parameters:
      mbinding - the method binding information on the method
      Returns:
      the signature string
    • getParameterString

      protected static String getParameterString(org.eclipse.jdt.core.dom.IMethodBinding mbinding)
      Obtains the string that represents parameters of a method having a given method binding information.
      Parameters:
      mbinding - the method binding information
      Returns:
      the string representing the parameters
    • getEnclosingElement

      public static org.eclipse.jdt.core.dom.ASTNode getEnclosingElement(org.eclipse.jdt.core.dom.ASTNode node, int sort)
      Finds an ancestor of a given AST node, having a specified sort.
      Parameters:
      node - the node of interest
      sort - the value representing the sort
      Returns:
      the found node, or null if no node is found
    • findEnclosingClass

      public static org.eclipse.jdt.core.dom.ITypeBinding findEnclosingClass(org.eclipse.jdt.core.dom.ASTNode node)
      Finds a class enclosing a given AST node.
      Parameters:
      node - the node of interest
      Returns:
      the type binding information on the found class, or null if no class is found
    • findEnclosingMethod

      public static org.eclipse.jdt.core.dom.IMethodBinding findEnclosingMethod(org.eclipse.jdt.core.dom.ASTNode node)
      Finds a method enclosing a given AST node.
      Parameters:
      node - the node of interest
      Returns:
      the method binding information on the found method, or null if no method is found
    • getType

      protected String getType(org.eclipse.jdt.core.dom.ITypeBinding tbinding)
      Returns the string representing type.
      Parameters:
      tbinding - the type binding
      Returns:
      the type string