mirror of
https://github.com/github/codeql.git
synced 2026-04-30 19:26:02 +02:00
Kotlin: Add a Kotlin 2 copy of the testsuite
This commit is contained in:
39
java/ql/test-kotlin2/library-tests/exprs/exprs.ql
Normal file
39
java/ql/test-kotlin2/library-tests/exprs/exprs.ql
Normal file
@@ -0,0 +1,39 @@
|
||||
import java
|
||||
|
||||
newtype TMaybeElement =
|
||||
TElement(Element e) or
|
||||
TNoElement()
|
||||
|
||||
class MaybeElement extends TMaybeElement {
|
||||
abstract string toString();
|
||||
|
||||
abstract Location getLocation();
|
||||
}
|
||||
|
||||
class YesMaybeElement extends MaybeElement {
|
||||
Element e;
|
||||
|
||||
YesMaybeElement() { this = TElement(e) }
|
||||
|
||||
override string toString() { result = e.toString() }
|
||||
|
||||
override Location getLocation() { result = e.getLocation() }
|
||||
}
|
||||
|
||||
class NoMaybeElement extends MaybeElement {
|
||||
NoMaybeElement() { this = TNoElement() }
|
||||
|
||||
override string toString() { result = "<none>" }
|
||||
|
||||
override Location getLocation() { none() }
|
||||
}
|
||||
|
||||
MaybeElement enclosingCallable(Expr e) {
|
||||
if exists(e.getEnclosingCallable())
|
||||
then result = TElement(e.getEnclosingCallable())
|
||||
else result = TNoElement()
|
||||
}
|
||||
|
||||
from Expr e
|
||||
where e.getFile().isSourceFile()
|
||||
select e, enclosingCallable(e), e.getPrimaryQlClasses()
|
||||
Reference in New Issue
Block a user