@@ -2,16 +2,44 @@ private import codeql.swift.generated.decl.TypeDecl
22private import codeql.swift.elements.type.AnyGenericType
33private import swift
44
5+ /**
6+ * A Swift type declaration, for example a class, struct, enum or protocol
7+ * declaration.
8+ *
9+ * Type declarations are distinct from types. A type declaration represents
10+ * the code that declares a type, for example:
11+ * ```
12+ * class MyClass {
13+ * ...
14+ * }
15+ * ```
16+ * Not all types have type declarations, for example built-in types do not
17+ * have type declarations.
18+ */
519class TypeDecl extends Generated:: TypeDecl {
620 override string toString ( ) { result = this .getName ( ) }
721
22+ /**
23+ * Gets the declaration of the `index`th base type of this type declaration (0-based).
24+ */
825 TypeDecl getBaseTypeDecl ( int i ) { result = this .getBaseType ( i ) .( AnyGenericType ) .getDeclaration ( ) }
926
27+ /**
28+ * Gets the declaration of any of the base types of this type declaration.
29+ */
1030 TypeDecl getABaseTypeDecl ( ) { result = this .getBaseTypeDecl ( _) }
1131
12- TypeDecl getDerivedTypeDecl ( int i ) { result .getBaseTypeDecl ( i ) = this }
32+ /**
33+ * Gets a declaration that has this type as its `index`th base type.
34+ *
35+ * DEPRECATED: The index is not very meaningful here. Use `getADerivedTypeDecl` or `getBaseTypeDecl`.
36+ */
37+ deprecated TypeDecl getDerivedTypeDecl ( int i ) { result .getBaseTypeDecl ( i ) = this }
1338
14- TypeDecl getADerivedTypeDecl ( ) { result = this .getDerivedTypeDecl ( _) }
39+ /**
40+ * Gets the declaration of any type derived from this type declaration.
41+ */
42+ TypeDecl getADerivedTypeDecl ( ) { result .getBaseTypeDecl ( _) = this }
1543
1644 /**
1745 * Gets the full name of this `TypeDecl`. For example in:
0 commit comments