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
1414 * ```
1515 */
1616class 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-
3317 /**
3418 * Gets the `index`th enumeration element of this enumeration (0-based).
3519 */
3620 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+ )
4328 }
4429
4530 /**
You can’t perform that action at this time.
0 commit comments