Package org.jtool.cfg

Class JMethodReference

java.lang.Object
org.jtool.cfg.JReference
org.jtool.cfg.JMethodReference

public class JMethodReference extends JReference
An class that represents reference to a method or a constructor.
  • Field Details

    • nameNode

      protected final org.eclipse.jdt.core.dom.ASTNode nameNode
      The 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 reference
      nameNode - the node of the name part of this method reference
      mbinding - the method binding information on this reference
      args - 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

      public String getReceiverName()
      Returns the receiver name of the referenced element.
      Overrides:
      getReceiverName in class JReference
      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 class JReference
      Returns:
      true if this is a method reference, otherwise false
    • isMethod

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

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

      public boolean isEnumConstant()
      Tests if this is a reference to an enum constant.
      Returns:
      true if this is a enum constant reference, otherwise false
    • 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, otherwise false
    • 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, otherwise false
    • 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, otherwise false
    • isFinal

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

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

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

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

      public boolean isNative()
      Tests if this is a reference to a native method.
      Returns:
      true if this is a native method reference, otherwise false
    • 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, otherwise false
    • getExceptionTypes

      public Set<org.eclipse.jdt.core.dom.ITypeBinding> getExceptionTypes()
      Returns the exception types that the referenced method might throw.
      Returns:
      the collection of type binding information for the thrown exceptions
    • getArguments

      public List<org.eclipse.jdt.core.dom.Expression> 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

      public String getArgumentType(int index)
      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, otherwise false
    • hasReceiver

      public boolean hasReceiver()
      Tests if this method reference has a receiver.
      Returns:
      true this reference has a receiver, otherwise false
    • setReceiver

      public void setReceiver(CFGReceiver receiver)
      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

      public CFGReceiver 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, otherwise false
    • 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, otherwise false
    • setApproximatedTypes

      public void setApproximatedTypes(Set<org.jtool.cfg.internal.refmodel.JClass> types)
      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

      public Set<org.jtool.cfg.internal.refmodel.JClass> 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

      public Set<String> getApproximatedTypeNames()
      Returns the approximated type names of receiver associated to this node.
      Returns:
      the collection of the approximated type names
    • getTypeParameters

      public List<String> 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, otherwise false
    • toString

      public String toString()
      Obtains information on this method reference.
      Overrides:
      toString in class Object
      Returns:
      the string representing the information