Package org.jtool.cfg
Class JReference
java.lang.Object
org.jtool.cfg.JReference
- Direct Known Subclasses:
JMethodReference
,JVariableReference
An abstract class that represents a reference to a field, a local variable, or a method.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected 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
ory.m()
protected String
The type of the referenced element. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
JReference
(org.eclipse.jdt.core.dom.ASTNode node) Creates a new object that represents a reference. -
Method Summary
Modifier and TypeMethodDescriptionboolean
boolean
equals
(JReference jvar) 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 elementgetName()
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.getType()
Returns the type of the referenced element.protected String
getType
(org.eclipse.jdt.core.dom.ITypeBinding tbinding) Returns the string representing type.int
hashCode()
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
isPublic()
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 isvoid
.
-
Field Details
-
astNode
protected final org.eclipse.jdt.core.dom.ASTNode astNodeThe AST node corresponding to this reference. -
enclosingClassName
The name of a class that encloses the referencing element. -
enclosingMethodName
The name of a method that encloses the referencing element. -
declaringClassName
The name of a class that declares the referenced element. -
declaringMethodName
The name of a method that declares the referenced element. -
fqn
The fully-qualified name of the referenced name. -
name
The referenced name without its attributes. -
referenceForm
The form of this reference, e.g.,a
,x.b
ory.m()
-
type
The type of the referenced element. -
isPrimitiveType
protected boolean isPrimitiveTypeA flag that indicates whether the type of the referenced element is primitive. -
modifiers
protected int modifiersThe modifier information of the referenced element. -
inProject
protected boolean inProjectA flag that indicates whether the referenced element exists inside the target project. -
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
Returns the name of a class that encloses the referencing element.- Returns:
- the class name for the referencing element
-
getEnclosingMethodName
Returns the name of a method that encloses the referencing element.- Returns:
- the method name for the referencing element
-
getDeclaringClassName
Returns the name of a class that declares the referenced element.- Returns:
- the class name for the referenced element
-
getDeclaringMethodName
Returns the name of a method that declares the referenced element.- Returns:
- the method name for the referenced element
-
getName
Returns the name of the referenced element without its attributes.- Returns:
- the name
-
getSignature
Returns the signature of the referenced element.- Returns:
- the signature
-
getQualifiedName
Returns the fully-qualified name of the referenced element.- Returns:
- the fully-qualified name
-
getReferenceForm
Returns the reference name of the referenced element.- Returns:
- the reference name
-
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
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, otherwisefalse
-
isVoidType
public boolean isVoidType()Tests if the type of the referenced element isvoid
.- Returns:
true
if thevoid
type, otherwisefalse
-
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, otherwisefalse
-
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, otherwisefalse
-
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, otherwisefalse
-
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, otherwisefalse
-
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, otherwisefalse
-
isFieldAccess
public boolean isFieldAccess()Tests if this is a reference to a field.- Returns:
true
if this is a field reference, otherwisefalse
-
isLocalAccess
public boolean isLocalAccess()Tests if this is a reference to a local variable.- Returns:
true
if this is a local variable reference, otherwisefalse
-
isVariableAccess
public boolean isVariableAccess()Tests if this is a reference to a variable.- Returns:
true
if this is a variable reference, otherwisefalse
-
isMethodCall
public boolean isMethodCall()Tests if this is a reference to a method.- Returns:
true
if this is a method reference, otherwisefalse
-
isReturnValueReference
public boolean isReturnValueReference()Tests if this is a reference to the return value.- Returns:
true
if this is a return value reference, otherwisefalse
-
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, otherwisefalse
-
isAliasReference
public boolean isAliasReference()Tests if this is a reference to an alias variable.- Returns:
true
if this is an alias reference, otherwisefalse
-
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, otherwisefalse
-
isUnsupportedReference
public boolean isUnsupportedReference()Tests if this is a reference to an unsupported program element.- Returns:
true
if this is an unsupported reference, otherwisefalse
-
isAvailable
public boolean isAvailable()Tests if this reference is available.- Returns:
true
if this is a reference to an available element, otherwisefalse
-
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
-
equals
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() -
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, otherwisefalse
-
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, otherwisefalse
-
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, otherwisefalse
-
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, otherwisefalse
-
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, otherwisefalse
-
findEnclosingClassName
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
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
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
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
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
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 interestsort
- 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
Returns the string representing type.- Parameters:
tbinding
- the type binding- Returns:
- the type string
-