@@ -2,16 +2,44 @@ private import codeql.swift.generated.decl.TypeDecl
2
2
private import codeql.swift.elements.type.AnyGenericType
3
3
private import swift
4
4
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
+ */
5
19
class TypeDecl extends Generated:: TypeDecl {
6
20
override string toString ( ) { result = this .getName ( ) }
7
21
22
+ /**
23
+ * Gets the declaration of the `index`th base type of this type declaration (0-based).
24
+ */
8
25
TypeDecl getBaseTypeDecl ( int i ) { result = this .getBaseType ( i ) .( AnyGenericType ) .getDeclaration ( ) }
9
26
27
+ /**
28
+ * Gets the declaration of any of the base types of this type declaration.
29
+ */
10
30
TypeDecl getABaseTypeDecl ( ) { result = this .getBaseTypeDecl ( _) }
11
31
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 }
13
38
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 }
15
43
16
44
/**
17
45
* Gets the full name of this `TypeDecl`. For example in:
0 commit comments