Class TypeUtil

java.lang.Object
org.eclipse.cdt.core.browser.TypeUtil

public class TypeUtil extends Object
Restriction:
This class is not intended to be subclassed by clients.
Restriction:
This class is not intended to be instantiated by clients.
  • Constructor Details

    • TypeUtil

      public TypeUtil()
  • Method Details

    • isDeclaringType

      public static boolean isDeclaringType(ICElement elem)
    • isMemberType

      public static boolean isMemberType(ICElement elem)
    • getDeclaringType

      public static ICElement getDeclaringType(ICElement elem)
      Returns the type in which this member is declared, or null if this member is not declared in a type (for example, a top-level type). This is a handle-only method.
      Returns:
      the type in which this member is declared, or null if this member is not declared in a type (for example, a top-level type)
    • getDeclaringClass

      public static ICElement getDeclaringClass(ICElement type)
    • isClassOrStruct

      public static boolean isClassOrStruct(ICElement type)
    • isClass

      public static boolean isClass(ICElement type)
    • isNamespace

      public static boolean isNamespace(ICElement type)
    • getTypes

      public static ICElement[] getTypes(ITranslationUnit tu) throws CModelException
      Returns the top-level types declared in the given translation unit in the order in which they appear in the source.
      Parameters:
      tu - the translation unit
      Returns:
      the top-level types declared in the given translation unit
      Throws:
      CModelException - if this element does not exist or if an exception occurs while accessing its corresponding resource
    • getAllTypes

      public static ICElement[] getAllTypes(ITranslationUnit tu) throws CModelException
      Returns all types declared in the given translation unit in the order in which they appear in the source. This includes all top-level types and nested member types. It does NOT include local types (types defined in methods).
      Returns:
      the array of top-level and member types defined in the given translation unit, in declaration order.
      Throws:
      CModelException - if this element does not exist or if an exception occurs while accessing its corresponding resource
    • getTypes

      public static ICElement[] getTypes(ICElement elem) throws CModelException
      Returns the immediate member types declared by the given element. The results are listed in the order in which they appear in the source file.
      Parameters:
      elem - the element
      Returns:
      the immediate member types declared by this type
      Throws:
      CModelException - if this element does not exist or if an exception occurs while accessing its corresponding resource.
    • getTranslationUnit

      public static ITranslationUnit getTranslationUnit(ICElement elem)
    • getFullyQualifiedName

      public static IQualifiedTypeName getFullyQualifiedName(ICElement type)
    • getMethods

      public static IMethodDeclaration[] getMethods(ICElement elem)
    • getFields

      public static ICElement[] getFields(ICElement elem)
    • findMethod

      public static IMethodDeclaration findMethod(String name, String[] paramTypes, boolean isConstructor, boolean isDestructor, IMethodDeclaration[] methods) throws CModelException
      Finds a method by name. This searches for a method with a name and signature. Parameter types are only compared by the simple name, no resolving for the fully qualified type name is done. Constructors are only compared by parameters, not the name.
      Parameters:
      name - The name of the method to find
      paramTypes - The type signatures of the parameters e.g. {"QString;","I"}
      isConstructor - If the method is a constructor
      methods - The methods to search in
      Returns:
      The found method or null, if nothing found
      Throws:
      CModelException
    • isSameMethodSignature

      public static boolean isSameMethodSignature(String name, String[] paramTypes, boolean isConstructor, boolean isDestructor, IMethodDeclaration curr) throws CModelException
      Tests if a method equals to the given signature. Parameter types are only compared by the simple name, no resolving for the fully qualified type name is done. Constructors are only compared by parameters, not the name.
      Parameters:
      name - Name of the method
      paramTypes - The type signatures of the parameters e.g. {"QString;","I"}
      isConstructor - Specifies if the method is a constructor
      Returns:
      Returns true if the method has the given name and parameter types and constructor state.
      Throws:
      CModelException
    • findMethod

      public static IMethodDeclaration findMethod(String name, String[] paramTypes, boolean isConstructor, boolean isDestructor, ICElement type) throws CModelException
      Finds a method in a type. This searches for a method with the same name and signature. Parameter types are only compared by the simple name, no resolving for the fully qualified type name is done. Constructors are only compared by parameters, not the name.
      Parameters:
      name - The name of the method to find
      paramTypes - The type signatures of the parameters e.g. {"QString;","I"}
      isConstructor - If the method is a constructor
      Returns:
      The first found method or null, if nothing found
      Throws:
      CModelException