Class JavaElementUtil

java.lang.Object
org.jtool.srcmodel.JavaElementUtil

public class JavaElementUtil extends Object
A root object for a Java model element.
  • Method Details

    • findQualifiedName

      public static QualifiedName findQualifiedName(org.eclipse.jdt.core.dom.ITypeBinding tbinding)
      Finds the fully-qualified name of a class having given type binding information.
      Parameters:
      tbinding - the type binding information on the class
      Returns:
      the fully-qualified name
    • findDeclaringClass

      public static JavaClass findDeclaringClass(org.eclipse.jdt.core.dom.ITypeBinding tbinding, JavaProject jproject)
      Finds a class having given type binding information within a given project.
      Parameters:
      tbinding - the type binding information on the class
      jproject - the project which the class might exist in
      Returns:
      the found class, or null if no class is found
    • findDeclaringMethod

      public static JavaMethod findDeclaringMethod(org.eclipse.jdt.core.dom.IMethodBinding mbinding, JavaProject jproject)
      Finds a method having given method binding information within a given project.
      Parameters:
      mbinding - the method binding information on the method
      jproject - the project which the class might exist in
      Returns:
      the found method, or null if no method is found
    • findDeclaringField

      public static JavaField findDeclaringField(org.eclipse.jdt.core.dom.IVariableBinding vbinding, JavaProject jproject)
      Finds a having given variable binding information within a given project.
      Parameters:
      vbinding - the variable binding information on the field
      jproject - the project which the class might exist in
      Returns:
      the found field, or null if no field is found
    • findAncestorNode

      public static org.eclipse.jdt.core.dom.ASTNode findAncestorNode(org.eclipse.jdt.core.dom.ASTNode node, int sort)
      Finds an ancestor of an AST node for this model element, having a specified sort.
      Parameters:
      node - the base AST node
      sort - the value representing the sort (e.g., ASTNode.TYPE_DECLARATION for the type declaration)
      Returns:
      the found ancestor, or null if no AST node is found
    • findEnclosingClass

      public static JavaClass findEnclosingClass(org.eclipse.jdt.core.dom.ASTNode node, JavaProject jproject)
      Finds a class that encloses a given model element within a given project.
      Parameters:
      node - the enclosed model element
      jproject - the project that the model element exists
      Returns:
      the found class, or null if there is no class enclosing the model element
    • findEnclosingMethod

      public static JavaMethod findEnclosingMethod(org.eclipse.jdt.core.dom.ASTNode node, JavaProject jproject)
      Finds a method that encloses a given model element within a given project.
      Parameters:
      node - the enclosed model element
      jproject - the project that the model element exists
      Returns:
      the found method, or null if there is no method enclosing the model element
    • isVoid

      public static boolean isVoid(String type)
      Tests if the string indicates the void type.
      Parameters:
      type - the type string
      Returns:
      true if the string indicates the void type, otherwise false
    • isPrimitiveType

      public static boolean isPrimitiveType(String type)
      Tests if the string indicates the primitive type.
      Parameters:
      type - the type string
      Returns:
      true if the string indicates the primitive type, otherwise false