Package org.eclipse.cdt.core.browser
Class TypeUtil
java.lang.Object
org.eclipse.cdt.core.browser.TypeUtil
- Restriction:
- This class is not intended to be subclassed by clients.
- Restriction:
- This class is not intended to be instantiated by clients.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic IMethodDeclaration
findMethod
(String name, String[] paramTypes, boolean isConstructor, boolean isDestructor, ICElement type) Finds a method in a type.static IMethodDeclaration
findMethod
(String name, String[] paramTypes, boolean isConstructor, boolean isDestructor, IMethodDeclaration[] methods) Finds a method by name.static ICElement[]
Returns all types declared in the given translation unit in the order in which they appear in the source.static ICElement
getDeclaringClass
(ICElement type) static ICElement
getDeclaringType
(ICElement elem) Returns the type in which this member is declared, ornull
if this member is not declared in a type (for example, a top-level type).static ICElement[]
static IQualifiedTypeName
static IMethodDeclaration[]
getMethods
(ICElement elem) static ITranslationUnit
getTranslationUnit
(ICElement elem) static ICElement[]
Returns the immediate member types declared by the given element.static ICElement[]
Returns the top-level types declared in the given translation unit in the order in which they appear in the source.static boolean
static boolean
isClassOrStruct
(ICElement type) static boolean
isDeclaringType
(ICElement elem) static boolean
isMemberType
(ICElement elem) static boolean
isNamespace
(ICElement type) static boolean
isSameMethodSignature
(String name, String[] paramTypes, boolean isConstructor, boolean isDestructor, IMethodDeclaration curr) Tests if a method equals to the given signature.
-
Constructor Details
-
TypeUtil
public TypeUtil()
-
-
Method Details
-
isDeclaringType
-
isMemberType
-
getDeclaringType
Returns the type in which this member is declared, ornull
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
-
isClassOrStruct
-
isClass
-
isNamespace
-
getTypes
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
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
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
-
getFullyQualifiedName
-
getMethods
-
getFields
-
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 findparamTypes
- The type signatures of the parameters e.g.{"QString;","I"}
isConstructor
- If the method is a constructormethods
- 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 methodparamTypes
- 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 findparamTypes
- 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
-