Package org.jtool.cfg
Class JMethodReference
java.lang.Object
org.jtool.cfg.JReference
org.jtool.cfg.JMethodReference
An class that represents reference to a method or a constructor.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final org.eclipse.jdt.core.dom.ASTNode
The AST node corresponding to the name of this reference.Fields inherited from class org.jtool.cfg.JReference
astNode, codeRange, declaringClassName, declaringMethodName, enclosingClassName, enclosingMethodName, fqn, inProject, isPrimitiveType, modifiers, name, referenceForm, type
-
Constructor Summary
ConstructorsConstructorDescriptionJMethodReference
(org.eclipse.jdt.core.dom.ASTNode node, org.eclipse.jdt.core.dom.ASTNode nameNode, org.eclipse.jdt.core.dom.IMethodBinding mbinding, List<org.eclipse.jdt.core.dom.Expression> args) Creates a new object that represents a reference to a method or a constructor. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Tests if this is a reference to the same method.Returns the approximated type names of receiver associated to this node.Set<org.jtool.cfg.internal.refmodel.JClass>
Returns the approximated types of receiver associated to this node.org.eclipse.jdt.core.dom.Expression
getArgument
(int index) Obtains an argument specified by the index for the argument list.List<org.eclipse.jdt.core.dom.Expression>
Returns argument of the referencing method.int
Return the number of arguments of the referencing method.getArgumentType
(int index) Obtains the type of an argument specified by the index for the argument list.Set<org.eclipse.jdt.core.dom.ITypeBinding>
Returns the exception types that the referenced method might throw.org.eclipse.jdt.core.dom.ASTNode
Returns the AST node corresponding to the name of this reference.Returns the node corresponding to the receiver of this method reference.Returns the receiver name of the referenced element.Returns type parameter names.boolean
Tests if a method call corresponding to this reference has explicitly a receiver.boolean
Tests if this method reference has a receiver.boolean
Tests if this is a reference to a abstract method.boolean
isArgumentPrimitiveType
(int index) Tests if the type of an argument specified by the index is primitive.boolean
Tests if this is a reference to a constructor.boolean
Tests if this is a reference to an enum constant.boolean
isFinal()
Tests if this is a reference to a final method.boolean
isLocal()
Tests if this is a reference to a local method or constructor within the class itself.boolean
isMethod()
Tests if this is a reference to a method.boolean
Tests if this is a reference to a method.boolean
isNative()
Tests if this is a reference to a native method.boolean
isStatic()
Tests if this is a reference to a static method.boolean
Tests if this is a reference to a strict-floating-point method.boolean
isSuper()
Tests if this is a reference to a constructor within the parent class.boolean
Tests if this is a reference to a synchronized method.boolean
Tests if this is a reference to a method having the variable arity.void
setApproximatedTypes
(Set<org.jtool.cfg.internal.refmodel.JClass> types) Sets the approximated types of receiver associated to this node.void
setExplicitReceiver
(boolean bool) Sets if a method call corresponding to this reference has explicitly a receiver.void
setReceiver
(CFGReceiver receiver) Sets a receiver of this method reference.toString()
Obtains information on this method reference.Methods inherited from class org.jtool.cfg.JReference
equals, equals, findEnclosingClass, findEnclosingClassName, findEnclosingMethod, findEnclosingMethodName, getASTNode, getCodeRange, getDeclaringClassName, getDeclaringMethodName, getEnclosingClassName, getEnclosingElement, getEnclosingMethodName, getModifiers, getName, getParameterString, getQualifiedClassName, getQualifiedMethodName, getQualifiedName, getReferenceForm, getSignature, getSignature, getStartPosition, getType, getType, hashCode, isAliasReference, isAvailable, isConstructor, isDefault, isEnumConstant, isField, isFieldAccess, isInProject, isLocal, isLocalAccess, isMethod, isPrimitiveType, isPrivate, isProtected, isPublic, isReturnValueReference, isUncoveredFieldReference, isUnsupportedReference, isVariableAccess, isVersatileReference, isVoidType
-
Field Details
-
nameNode
protected final org.eclipse.jdt.core.dom.ASTNode nameNodeThe AST node corresponding to the name of this reference.
-
-
Constructor Details
-
JMethodReference
public JMethodReference(org.eclipse.jdt.core.dom.ASTNode node, org.eclipse.jdt.core.dom.ASTNode nameNode, org.eclipse.jdt.core.dom.IMethodBinding mbinding, List<org.eclipse.jdt.core.dom.Expression> args) Creates a new object that represents a reference to a method or a constructor. This constructor is not intended to be invoked by clients.- Parameters:
node
- the AST node corresponding to this referencenameNode
- the node of the name part of this method referencembinding
- the method binding information on this referenceargs
- the AST nodes corresponding to the arguments of this method reference
-
-
Method Details
-
getNameNode
public org.eclipse.jdt.core.dom.ASTNode getNameNode()Returns the AST node corresponding to the name of this reference.- Returns:
- the AST node of the name part
-
getReceiverName
Returns the receiver name of the referenced element.- Overrides:
getReceiverName
in classJReference
- Returns:
- the receiver name, or the empty string if the element does not have any receiver
-
isMethodCall
public boolean isMethodCall()Tests if this is a reference to a method.- Overrides:
isMethodCall
in classJReference
- Returns:
true
if this is a method reference, otherwisefalse
-
isMethod
public boolean isMethod()Tests if this is a reference to a method.- Returns:
true
if this is a method reference, otherwisefalse
-
isConstructor
public boolean isConstructor()Tests if this is a reference to a constructor.- Returns:
true
if this is a method reference, otherwisefalse
-
isEnumConstant
public boolean isEnumConstant()Tests if this is a reference to an enum constant.- Returns:
true
if this is a enum constant reference, otherwisefalse
-
isVarargs
public boolean isVarargs()Tests if this is a reference to a method having the variable arity.- Returns:
true
if this is a variable-arity method reference, otherwisefalse
-
isSuper
public boolean isSuper()Tests if this is a reference to a constructor within the parent class.- Returns:
true
if this is a reference to a constructor within the parent, otherwisefalse
-
isLocal
public boolean isLocal()Tests if this is a reference to a local method or constructor within the class itself.- Returns:
true
if this is a reference to a local method or constructor within the class itself, otherwisefalse
-
isFinal
public boolean isFinal()Tests if this is a reference to a final method.- Returns:
true
if this is a final method reference, otherwisefalse
-
isAbstract
public boolean isAbstract()Tests if this is a reference to a abstract method.- Returns:
true
if this is a abstract method reference, otherwisefalse
-
isStatic
public boolean isStatic()Tests if this is a reference to a static method.- Returns:
true
if this is a static method reference, otherwisefalse
-
isSynchronized
public boolean isSynchronized()Tests if this is a reference to a synchronized method.- Returns:
true
if this is a synchronized method reference, otherwisefalse
-
isNative
public boolean isNative()Tests if this is a reference to a native method.- Returns:
true
if this is a native method reference, otherwisefalse
-
isStrictfp
public boolean isStrictfp()Tests if this is a reference to a strict-floating-point method.- Returns:
true
if this is a strict-floating-point method reference, otherwisefalse
-
getExceptionTypes
Returns the exception types that the referenced method might throw.- Returns:
- the collection of type binding information for the thrown exceptions
-
getArguments
Returns argument of the referencing method.- Returns:
- the collection of the arguments
-
getArgumentSize
public int getArgumentSize()Return the number of arguments of the referencing method.- Returns:
- the number of the arguments
-
getArgument
public org.eclipse.jdt.core.dom.Expression getArgument(int index) Obtains an argument specified by the index for the argument list.- Parameters:
index
- the index number of the argument of the referencing method- Returns:
- the AST node of the found argument
-
getArgumentType
Obtains the type of an argument specified by the index for the argument list.- Parameters:
index
- the index number of the argument of the referencing method- Returns:
- the AST node of the found argument
-
isArgumentPrimitiveType
public boolean isArgumentPrimitiveType(int index) Tests if the type of an argument specified by the index is primitive.- Parameters:
index
- the index number of the argument of the referencing method- Returns:
true
if the type of the argument is primitive, otherwisefalse
-
hasReceiver
public boolean hasReceiver()Tests if this method reference has a receiver.- Returns:
true
this reference has a receiver, otherwisefalse
-
setReceiver
Sets a receiver of this method reference. This method is not intended to be invoked by clients.- Parameters:
receiver
- the receiver node to be set
-
getReceiver
Returns the node corresponding to the receiver of this method reference.- Returns:
- the receiver node
-
hasExplicitReceiver
public boolean hasExplicitReceiver()Tests if a method call corresponding to this reference has explicitly a receiver.- Returns:
true
a method call corresponding to this reference has a receiver, otherwisefalse
-
setExplicitReceiver
public void setExplicitReceiver(boolean bool) Sets if a method call corresponding to this reference has explicitly a receiver. This method is not intended to be invoked by clients.- Parameters:
bool
-true
a method call corresponding to this reference has a receiver, otherwisefalse
-
setApproximatedTypes
Sets the approximated types of receiver associated to this node. This method is not intended to be invoked by clients.- Parameters:
types
- the collection of the approximated types to be set
-
getApproximatedTypes
Returns the approximated types of receiver associated to this node. These types include classes declaring method that might be dynamically called. In the case of a field access, the approximated types are not supported because no dynamic binding is performed- Returns:
- the collection of the approximated types
-
getApproximatedTypeNames
Returns the approximated type names of receiver associated to this node.- Returns:
- the collection of the approximated type names
-
getTypeParameters
Returns type parameter names.- Returns:
- the collection of the type parameter names
-
callSelfDirectly
public boolean callSelfDirectly()Tests if this is a reference to the same method.- Returns:
true
if the referencing method is same as the referenced method, otherwisefalse
-
toString
Obtains information on this method reference.
-