Files
codeql/swift/ql/test/library-tests/elements/decl/enumdecl/enumdecl.ql
Jeroen Ketema ce5c48192e Swift: Make file checking in tests more strict
With Swift 6.1 the extractor will start to extract files outside of the test
directory. These files and their elements we do not want to see in our tests.
2025-04-22 10:41:12 +02:00

26 lines
807 B
Plaintext

import swift
string describe(Decl d) {
d instanceof EnumDecl and result = "(EnumDecl)"
or
d instanceof EnumCaseDecl and result = "(EnumCaseDecl)"
or
d instanceof EnumElementDecl and result = "(EnumElementDecl)"
or
result = ".getType = " + d.(EnumDecl).getType().toString()
or
result = ".getDeclaringDecl = " + d.getDeclaringDecl().toString()
or
exists(int i |
result = ".getElement(" + i.toString() + ") = " + d.(EnumCaseDecl).getElement(i).toString()
or
result = ".getParam(" + i.toString() + ") = " + d.(EnumElementDecl).getParam(i).toString()
or
result = ".getEnumElement(" + i.toString() + ") = " + d.(EnumDecl).getEnumElement(i).toString()
)
}
from Decl d
where exists(d.getLocation().getFile().getRelativePath())
select d, strictconcat(describe(d), ", ")