mirror of
https://github.com/github/codeql.git
synced 2026-04-26 17:25:19 +02:00
Kotlin: Add tests for file classes
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
| file1.kt:0:0:0:0 | File1Kt | File1Kt |
|
||||
| file1.kt:2:1:2:16 | Class1 | Class1 |
|
||||
| file1.kt:2:1:13:1 | Class1 | Class1 |
|
||||
| file2.kt:0:0:0:0 | File2Kt | File2Kt |
|
||||
| file2.kt:2:1:2:16 | Class2 | Class2 |
|
||||
| file2.kt:2:1:4:1 | Class2 | Class2 |
|
||||
| file3.kt:0:0:0:0 | MyJvmName | MyJvmName |
|
||||
| file3.kt:3:1:3:16 | Class3 | Class3 |
|
||||
| file4.kt:0:0:0:0 | File4Kt | File4Kt |
|
||||
| file4.kt:2:1:2:16 | Class4 | Class4 |
|
||||
|
||||
@@ -1,3 +1,14 @@
|
||||
|
||||
class Class1 { }
|
||||
class Class1 {
|
||||
fun fun1() {
|
||||
Class2().fun2()
|
||||
fun3()
|
||||
fun4()
|
||||
|
||||
// libraries/stdlib/jvm/runtime/kotlin/jvm/internal/CollectionToArray.kt
|
||||
// has a @file:JvmName("CollectionToArray") annotation, and contains
|
||||
// a function collectionToArray with a @JvmName("toArray") annotation.
|
||||
kotlin.jvm.internal.collectionToArray(listOf(1))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
|
||||
class Class2 { }
|
||||
class Class2 {
|
||||
fun fun2() { }
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
|
||||
class Class4 { }
|
||||
|
||||
fun fun4() {
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
| file1.kt:2:1:13:1 | <obinit>(...) | file1.kt:2:1:13:1 | <obinit> | Class1.<obinit> | file1.kt:2:1:13:1 | Class1 |
|
||||
| file1.kt:4:18:4:23 | fun2(...) | file2.kt:3:5:3:18 | fun2 | Class2.fun2 | file2.kt:2:1:4:1 | Class2 |
|
||||
| file1.kt:5:9:5:14 | fun3(...) | file3.kt:5:1:6:1 | fun3 | MyJvmName.fun3 | file3.kt:0:0:0:0 | MyJvmName |
|
||||
| file1.kt:6:9:6:14 | fun4(...) | file4.kt:4:1:5:1 | fun4 | File4Kt.fun4 | file4.kt:0:0:0:0 | File4Kt |
|
||||
| file1.kt:11:29:11:56 | collectionToArray(...) | file://<external>/CollectionToArray.class:0:0:0:0 | collectionToArray | CollectionToArray.collectionToArray | file://<external>/CollectionToArray.class:0:0:0:0 | CollectionToArray |
|
||||
| file1.kt:11:47:11:55 | listOf(...) | file://<external>/CollectionsKt.class:0:0:0:0 | listOf | CollectionsKt.listOf | file://<external>/CollectionsKt.class:0:0:0:0 | CollectionsKt |
|
||||
| file2.kt:2:1:4:1 | <obinit>(...) | file2.kt:2:1:4:1 | <obinit> | Class2.<obinit> | file2.kt:2:1:4:1 | Class2 |
|
||||
| file3.kt:3:1:3:16 | <obinit>(...) | file3.kt:3:1:3:16 | <obinit> | Class3.<obinit> | file3.kt:3:1:3:16 | Class3 |
|
||||
| file4.kt:2:1:2:16 | <obinit>(...) | file4.kt:2:1:2:16 | <obinit> | Class4.<obinit> | file4.kt:2:1:2:16 | Class4 |
|
||||
@@ -0,0 +1,27 @@
|
||||
import java
|
||||
|
||||
// Stop external filepaths from appearing in the results
|
||||
class ClassLocation extends Class {
|
||||
override predicate hasLocationInfo(string path, int sl, int sc, int el, int ec) {
|
||||
exists(string fullPath |
|
||||
super.hasLocationInfo(fullPath, sl, sc, el, ec) |
|
||||
if exists(this.getFile().getRelativePath())
|
||||
then path = fullPath
|
||||
else path = fullPath.regexpReplaceAll(".*/", "<external>/"))
|
||||
}
|
||||
}
|
||||
class MethodLocation extends Method {
|
||||
override predicate hasLocationInfo(string path, int sl, int sc, int el, int ec) {
|
||||
exists(string fullPath |
|
||||
super.hasLocationInfo(fullPath, sl, sc, el, ec) |
|
||||
if exists(this.getFile().getRelativePath())
|
||||
then path = fullPath
|
||||
else path = fullPath.regexpReplaceAll(".*/", "<external>/"))
|
||||
}
|
||||
}
|
||||
|
||||
from MethodAccess ma, Method m
|
||||
where ma.getFile().(CompilationUnit).fromSource()
|
||||
and m = ma.getMethod()
|
||||
select ma, m, m.getQualifiedName(), m.getDeclaringType()
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
| file1.kt:2:1:13:1 | <obinit> | Class1.<obinit> | file1.kt:2:1:13:1 | Class1 |
|
||||
| file1.kt:2:1:13:1 | equals | Class1.equals | file1.kt:2:1:13:1 | Class1 |
|
||||
| file1.kt:2:1:13:1 | hashCode | Class1.hashCode | file1.kt:2:1:13:1 | Class1 |
|
||||
| file1.kt:2:1:13:1 | toString | Class1.toString | file1.kt:2:1:13:1 | Class1 |
|
||||
| file1.kt:3:5:12:5 | fun1 | Class1.fun1 | file1.kt:2:1:13:1 | Class1 |
|
||||
| file2.kt:2:1:4:1 | <obinit> | Class2.<obinit> | file2.kt:2:1:4:1 | Class2 |
|
||||
| file2.kt:2:1:4:1 | equals | Class2.equals | file2.kt:2:1:4:1 | Class2 |
|
||||
| file2.kt:2:1:4:1 | hashCode | Class2.hashCode | file2.kt:2:1:4:1 | Class2 |
|
||||
| file2.kt:2:1:4:1 | toString | Class2.toString | file2.kt:2:1:4:1 | Class2 |
|
||||
| file2.kt:3:5:3:18 | fun2 | Class2.fun2 | file2.kt:2:1:4:1 | Class2 |
|
||||
| file3.kt:3:1:3:16 | <obinit> | Class3.<obinit> | file3.kt:3:1:3:16 | Class3 |
|
||||
| file3.kt:3:1:3:16 | equals | Class3.equals | file3.kt:3:1:3:16 | Class3 |
|
||||
| file3.kt:3:1:3:16 | hashCode | Class3.hashCode | file3.kt:3:1:3:16 | Class3 |
|
||||
| file3.kt:3:1:3:16 | toString | Class3.toString | file3.kt:3:1:3:16 | Class3 |
|
||||
| file3.kt:5:1:6:1 | fun3 | MyJvmName.fun3 | file3.kt:0:0:0:0 | MyJvmName |
|
||||
| file4.kt:2:1:2:16 | <obinit> | Class4.<obinit> | file4.kt:2:1:2:16 | Class4 |
|
||||
| file4.kt:2:1:2:16 | equals | Class4.equals | file4.kt:2:1:2:16 | Class4 |
|
||||
| file4.kt:2:1:2:16 | hashCode | Class4.hashCode | file4.kt:2:1:2:16 | Class4 |
|
||||
| file4.kt:2:1:2:16 | toString | Class4.toString | file4.kt:2:1:2:16 | Class4 |
|
||||
| file4.kt:4:1:5:1 | fun4 | File4Kt.fun4 | file4.kt:0:0:0:0 | File4Kt |
|
||||
@@ -0,0 +1,6 @@
|
||||
import java
|
||||
|
||||
from Method m
|
||||
where m.fromSource()
|
||||
select m, m.getQualifiedName(), m.getDeclaringType()
|
||||
|
||||
Reference in New Issue
Block a user