File tree Expand file tree Collapse file tree 1 file changed +7
-22
lines changed
swift/ql/lib/codeql/swift/elements/decl Expand file tree Collapse file tree 1 file changed +7
-22
lines changed Original file line number Diff line number Diff line change @@ -14,32 +14,17 @@ private import codeql.swift.elements.decl.Decl
14
14
* ```
15
15
*/
16
16
class EnumDecl extends Generated:: EnumDecl {
17
- /**
18
- * Gets the number of `EnumElementDecl`s in this enumeration before the `memberIndex`th member. Some
19
- * of the members of an `EnumDecl` are `EnumCaseDecls` (representing the `case` lines), each of
20
- * which holds one or more `EnumElementDecl`s.
21
- */
22
- private int countEnumElementsTo ( int memberIndex ) {
23
- memberIndex = 0 and result = 0
24
- or
25
- exists ( Decl prev | prev = this .getMember ( memberIndex - 1 ) |
26
- result = this .countEnumElementsTo ( memberIndex - 1 ) + prev .( EnumCaseDecl ) .getNumberOfElements ( )
27
- or
28
- not prev instanceof EnumCaseDecl and
29
- result = this .countEnumElementsTo ( memberIndex - 1 )
30
- )
31
- }
32
-
33
17
/**
34
18
* Gets the `index`th enumeration element of this enumeration (0-based).
35
19
*/
36
20
final EnumElementDecl getEnumElement ( int index ) {
37
- exists ( int memberIndex |
38
- result =
39
- this .getMember ( memberIndex )
40
- .( EnumCaseDecl )
41
- .getElement ( index - this .countEnumElementsTo ( memberIndex ) )
42
- )
21
+ result =
22
+ rank [ index + 1 ] ( int memberIndex , Decl d |
23
+ d = this .getMember ( memberIndex ) and
24
+ d instanceof EnumElementDecl
25
+ |
26
+ d order by memberIndex
27
+ )
43
28
}
44
29
45
30
/**
You can’t perform that action at this time.
0 commit comments