mirror of
https://github.com/github/codeql.git
synced 2026-05-01 11:45:14 +02:00
Merge branch 'main' into static-useInstanceOf
This commit is contained in:
@@ -53,6 +53,8 @@ predicate shouldBeDeadEnd(ControlFlowNode n) {
|
||||
not exists(n.getFile().getRelativePath()) // TODO
|
||||
or
|
||||
n = any(ConstCase c).getValue(_) // TODO
|
||||
or
|
||||
n instanceof ErrorExpr // TODO
|
||||
}
|
||||
|
||||
from ControlFlowNode n, string s
|
||||
|
||||
@@ -41,7 +41,12 @@ predicate gapInChildren(Element e, int i) {
|
||||
// -1 can be skipped (type arguments from -2 down, no qualifier at -1,
|
||||
// then arguments from 0).
|
||||
// Can we also skip arguments, e.g. due to defaults for parameters?
|
||||
not (e instanceof MethodAccess and e.getFile().isKotlinSourceFile())
|
||||
not (e instanceof MethodAccess and e.getFile().isKotlinSourceFile()) and
|
||||
// Kotlin-extracted annotations can have missing children where a default
|
||||
// value should be, because kotlinc doesn't load annotation defaults and we
|
||||
// want to leave a space for another extractor to fill in the default if it
|
||||
// is able.
|
||||
not e instanceof Annotation
|
||||
}
|
||||
|
||||
predicate lateFirstChild(Element e, int i) {
|
||||
@@ -59,7 +64,12 @@ predicate lateFirstChild(Element e, int i) {
|
||||
not (e instanceof LocalVariableDeclStmt and i = 1 and not exists(nthChildOf(e, 2))) and
|
||||
// For statements may or may not declare a new variable (child 0), or
|
||||
// have a condition (child 1).
|
||||
not (e instanceof ForStmt and i = [1, 2])
|
||||
not (e instanceof ForStmt and i = [1, 2]) and
|
||||
// Kotlin-extracted annotations can have missing children where a default
|
||||
// value should be, because kotlinc doesn't load annotation defaults and we
|
||||
// want to leave a space for another extractor to fill in the default if it
|
||||
// is able.
|
||||
not e instanceof Annotation
|
||||
}
|
||||
|
||||
from Element e, int i, string problem
|
||||
|
||||
@@ -0,0 +1,301 @@
|
||||
User.java:
|
||||
# 0| [CompilationUnit] User
|
||||
# 1| 1: [Class] User
|
||||
# 3| 2: [Method] user
|
||||
# 3| 3: [TypeAccess] void
|
||||
#-----| 4: (Parameters)
|
||||
# 3| 0: [Parameter] a1
|
||||
# 3| 0: [TypeAccess] Ann1
|
||||
# 3| 1: [Parameter] a2
|
||||
# 3| 0: [TypeAccess] Ann2
|
||||
# 3| 5: [BlockStmt] { ... }
|
||||
# 4| 0: [ExprStmt] <Expr>;
|
||||
# 4| 0: [MethodAccess] x(...)
|
||||
# 4| -1: [VarAccess] a1
|
||||
# 4| 1: [ExprStmt] <Expr>;
|
||||
# 4| 0: [MethodAccess] z(...)
|
||||
# 4| -1: [VarAccess] a2
|
||||
# 4| 2: [ExprStmt] <Expr>;
|
||||
# 4| 0: [ClassInstanceExpr] new Annotated(...)
|
||||
# 4| -3: [TypeAccess] Annotated
|
||||
# 4| 3: [ExprStmt] <Expr>;
|
||||
# 4| 0: [ClassInstanceExpr] new HasJavaDeprecatedAnnotationUsedByJava(...)
|
||||
# 4| -3: [TypeAccess] HasJavaDeprecatedAnnotationUsedByJava
|
||||
# 4| 4: [ExprStmt] <Expr>;
|
||||
# 4| 0: [ClassInstanceExpr] new HasKotlinDeprecatedAnnotationUsedByJava(...)
|
||||
# 4| -3: [TypeAccess] HasKotlinDeprecatedAnnotationUsedByJava
|
||||
ktUser.kt:
|
||||
# 0| [CompilationUnit] ktUser
|
||||
# 1| 1: [Class] KtUser
|
||||
# 1| 1: [Constructor] KtUser
|
||||
# 1| 5: [BlockStmt] { ... }
|
||||
# 1| 0: [SuperConstructorInvocationStmt] super(...)
|
||||
# 1| 1: [BlockStmt] { ... }
|
||||
# 3| 2: [Method] user
|
||||
# 3| 3: [TypeAccess] Unit
|
||||
# 3| 5: [BlockStmt] { ... }
|
||||
# 4| 0: [LocalVariableDeclStmt] var ...;
|
||||
# 4| 1: [LocalVariableDeclExpr] a
|
||||
# 4| 0: [ClassInstanceExpr] new AnnotatedUsedByKotlin(...)
|
||||
# 4| -3: [TypeAccess] AnnotatedUsedByKotlin
|
||||
# 5| 1: [LocalVariableDeclStmt] var ...;
|
||||
# 5| 1: [LocalVariableDeclExpr] b
|
||||
# 5| 0: [ClassInstanceExpr] new HasJavaDeprecatedAnnotationUsedByKotlin(...)
|
||||
# 5| -3: [TypeAccess] HasJavaDeprecatedAnnotationUsedByKotlin
|
||||
# 6| 2: [LocalVariableDeclStmt] var ...;
|
||||
# 6| 1: [LocalVariableDeclExpr] c
|
||||
# 6| 0: [ClassInstanceExpr] new HasKotlinDeprecatedAnnotationUsedByKotlin(...)
|
||||
# 6| -3: [TypeAccess] HasKotlinDeprecatedAnnotationUsedByKotlin
|
||||
# 8| 3: [ExprStmt] <Expr>;
|
||||
# 8| 0: [ImplicitCoercionToUnitExpr] <implicit coercion to unit>
|
||||
# 8| 0: [TypeAccess] Unit
|
||||
# 8| 1: [MethodAccess] isJavaLetter(...)
|
||||
# 8| -1: [TypeAccess] Character
|
||||
# 8| 0: [CharacterLiteral] a
|
||||
test.kt:
|
||||
# 0| [CompilationUnit] test
|
||||
# 4| 1: [Interface] Ann1
|
||||
#-----| -3: (Annotations)
|
||||
# 0| 1: [Annotation] Retention
|
||||
# 0| 1: [VarAccess] RetentionPolicy.RUNTIME
|
||||
# 0| -1: [TypeAccess] RetentionPolicy
|
||||
# 4| 1: [Method] x
|
||||
# 4| 3: [TypeAccess] int
|
||||
# 4| 2: [Method] y
|
||||
# 4| 3: [TypeAccess] Ann2
|
||||
# 4| 3: [Method] z
|
||||
# 4| 3: [TypeAccess] DayOfWeek
|
||||
# 6| 2: [Interface] Ann2
|
||||
#-----| -3: (Annotations)
|
||||
# 0| 1: [Annotation] Retention
|
||||
# 0| 1: [VarAccess] RetentionPolicy.RUNTIME
|
||||
# 0| -1: [TypeAccess] RetentionPolicy
|
||||
# 6| 1: [Method] z
|
||||
# 6| 3: [TypeAccess] String
|
||||
# 6| 2: [Method] w
|
||||
# 6| 3: [TypeAccess] Class<?>
|
||||
# 6| 0: [WildcardTypeAccess] ? ...
|
||||
# 6| 3: [Method] v
|
||||
# 6| 3: [TypeAccess] int[]
|
||||
# 6| 4: [Method] u
|
||||
# 6| 3: [TypeAccess] Ann3[]
|
||||
# 6| 0: [TypeAccess] Ann3
|
||||
# 6| 5: [Method] t
|
||||
# 6| 3: [TypeAccess] Class<?>[]
|
||||
# 6| 0: [TypeAccess] Class<?>
|
||||
# 6| 0: [WildcardTypeAccess] ? ...
|
||||
# 8| 3: [Interface] Ann3
|
||||
#-----| -3: (Annotations)
|
||||
# 0| 1: [Annotation] Retention
|
||||
# 0| 1: [VarAccess] RetentionPolicy.RUNTIME
|
||||
# 0| -1: [TypeAccess] RetentionPolicy
|
||||
# 8| 1: [Method] a
|
||||
# 8| 3: [TypeAccess] int
|
||||
# 10| 4: [GenericType,Interface,ParameterizedType] GenericAnnotation
|
||||
#-----| -3: (Annotations)
|
||||
# 0| 1: [Annotation] Retention
|
||||
# 0| 1: [VarAccess] RetentionPolicy.RUNTIME
|
||||
# 0| -1: [TypeAccess] RetentionPolicy
|
||||
#-----| -2: (Generic Parameters)
|
||||
# 10| 0: [TypeVariable] T
|
||||
# 10| 1: [Method] x
|
||||
# 10| 3: [TypeAccess] Class<T>
|
||||
# 10| 0: [TypeAccess] T
|
||||
# 10| 2: [Method] y
|
||||
# 10| 3: [TypeAccess] Class<T>[]
|
||||
# 10| 0: [TypeAccess] Class<T>
|
||||
# 10| 0: [TypeAccess] T
|
||||
# 12| 6: [Interface] VarargAnnotation
|
||||
#-----| -3: (Annotations)
|
||||
# 0| 1: [Annotation] Repeatable
|
||||
# 0| 1: [TypeLiteral] Container.class
|
||||
# 0| 0: [TypeAccess] Container
|
||||
# 0| 2: [Annotation] Retention
|
||||
# 0| 1: [VarAccess] RetentionPolicy.RUNTIME
|
||||
# 0| -1: [TypeAccess] RetentionPolicy
|
||||
# 12| 3: [Annotation] Repeatable
|
||||
# 0| 1: [Interface] Container
|
||||
#-----| -3: (Annotations)
|
||||
# 0| 1: [Annotation] RepeatableContainer
|
||||
# 0| 2: [Annotation] Retention
|
||||
# 0| 1: [VarAccess] RetentionPolicy.RUNTIME
|
||||
# 0| -1: [TypeAccess] RetentionPolicy
|
||||
# 0| 1: [Method] value
|
||||
# 0| 3: [TypeAccess] VarargAnnotation[]
|
||||
# 0| 0: [TypeAccess] VarargAnnotation
|
||||
# 13| 2: [Method] x
|
||||
# 13| 3: [TypeAccess] int[]
|
||||
# 15| 7: [Interface] AnnWithDefaults
|
||||
#-----| -3: (Annotations)
|
||||
# 0| 1: [Annotation] Retention
|
||||
# 0| 1: [VarAccess] RetentionPolicy.RUNTIME
|
||||
# 0| -1: [TypeAccess] RetentionPolicy
|
||||
# 15| 1: [Method] x
|
||||
# 15| 3: [TypeAccess] int
|
||||
# 15| 2: [Method] y
|
||||
# 15| 3: [TypeAccess] String
|
||||
# 15| 3: [Method] z
|
||||
# 15| 3: [TypeAccess] DayOfWeek
|
||||
# 15| 4: [Method] w
|
||||
# 15| 3: [TypeAccess] Ann3[]
|
||||
# 15| 0: [TypeAccess] Ann3
|
||||
# 17| 8: [Class] Annotated
|
||||
#-----| -3: (Annotations)
|
||||
# 0| 1: [Annotation] Container
|
||||
# 0| 1: [ArrayInit] {...}
|
||||
# 19| 1: [Annotation] VarargAnnotation
|
||||
# 0| 1: [ArrayInit] {...}
|
||||
# 20| 2: [Annotation] VarargAnnotation
|
||||
# 0| 1: [ArrayInit] {...}
|
||||
# 0| 1: [IntegerLiteral] 1
|
||||
# 21| 3: [Annotation] VarargAnnotation
|
||||
# 0| 1: [ArrayInit] {...}
|
||||
# 0| 1: [IntegerLiteral] 1
|
||||
# 0| 2: [IntegerLiteral] 2
|
||||
# 22| 4: [Annotation] VarargAnnotation
|
||||
# 0| 1: [ArrayInit] {...}
|
||||
# 0| 1: [IntegerLiteral] 1
|
||||
# 0| 2: [IntegerLiteral] 2
|
||||
# 0| 3: [IntegerLiteral] 3
|
||||
# 23| 5: [Annotation] VarargAnnotation
|
||||
# 0| 1: [ArrayInit] {...}
|
||||
# 0| 1: [IntegerLiteral] 1
|
||||
# 0| 2: [IntegerLiteral] 2
|
||||
# 0| 3: [IntegerLiteral] 3
|
||||
# 17| 2: [Annotation] Ann1
|
||||
# 0| 1: [IntegerLiteral] 1
|
||||
# 0| 2: [Annotation] Ann2
|
||||
# 0| 1: [StringLiteral] "Hello"
|
||||
# 0| 2: [TypeLiteral] String.class
|
||||
# 0| 0: [TypeAccess] String
|
||||
# 0| 3: [ArrayInit] {...}
|
||||
# 0| 1: [IntegerLiteral] 1
|
||||
# 0| 2: [IntegerLiteral] 2
|
||||
# 0| 3: [IntegerLiteral] 3
|
||||
# 0| 4: [ArrayInit] {...}
|
||||
# 0| 1: [Annotation] Ann3
|
||||
# 0| 1: [IntegerLiteral] 1
|
||||
# 0| 2: [Annotation] Ann3
|
||||
# 0| 1: [IntegerLiteral] 2
|
||||
# 0| 5: [ArrayInit] {...}
|
||||
# 0| 1: [TypeLiteral] String.class
|
||||
# 0| 0: [TypeAccess] String
|
||||
# 0| 2: [TypeLiteral] int.class
|
||||
# 0| 0: [TypeAccess] int
|
||||
# 0| 3: [VarAccess] DayOfWeek.MONDAY
|
||||
# 0| -1: [TypeAccess] DayOfWeek
|
||||
# 18| 3: [Annotation] GenericAnnotation
|
||||
# 0| 1: [TypeLiteral] String.class
|
||||
# 0| 0: [TypeAccess] String
|
||||
# 0| 2: [ArrayInit] {...}
|
||||
# 0| 1: [TypeLiteral] String.class
|
||||
# 0| 0: [TypeAccess] String
|
||||
# 0| 2: [TypeLiteral] String.class
|
||||
# 0| 0: [TypeAccess] String
|
||||
# 24| 4: [Annotation] AnnWithDefaults
|
||||
# 0| 1: [IntegerLiteral] 1
|
||||
# 0| 2: [StringLiteral] "hello"
|
||||
# 0| 3: [VarAccess] DayOfWeek.TUESDAY
|
||||
# 0| -1: [TypeAccess] DayOfWeek
|
||||
# 0| 4: [ArrayInit] {...}
|
||||
# 0| 1: [Annotation] Ann3
|
||||
# 0| 1: [IntegerLiteral] 1
|
||||
# 25| 1: [Constructor] Annotated
|
||||
# 17| 5: [BlockStmt] { ... }
|
||||
# 17| 0: [SuperConstructorInvocationStmt] super(...)
|
||||
# 25| 1: [BlockStmt] { ... }
|
||||
# 27| 9: [Class] AnnotatedUsedByKotlin
|
||||
#-----| -3: (Annotations)
|
||||
# 0| 1: [Annotation] Container
|
||||
# 0| 1: [ArrayInit] {...}
|
||||
# 29| 1: [Annotation] VarargAnnotation
|
||||
# 0| 1: [ArrayInit] {...}
|
||||
# 30| 2: [Annotation] VarargAnnotation
|
||||
# 0| 1: [ArrayInit] {...}
|
||||
# 0| 1: [IntegerLiteral] 1
|
||||
# 31| 3: [Annotation] VarargAnnotation
|
||||
# 0| 1: [ArrayInit] {...}
|
||||
# 0| 1: [IntegerLiteral] 1
|
||||
# 0| 2: [IntegerLiteral] 2
|
||||
# 32| 4: [Annotation] VarargAnnotation
|
||||
# 0| 1: [ArrayInit] {...}
|
||||
# 0| 1: [IntegerLiteral] 1
|
||||
# 0| 2: [IntegerLiteral] 2
|
||||
# 0| 3: [IntegerLiteral] 3
|
||||
# 33| 5: [Annotation] VarargAnnotation
|
||||
# 0| 1: [ArrayInit] {...}
|
||||
# 0| 1: [IntegerLiteral] 1
|
||||
# 0| 2: [IntegerLiteral] 2
|
||||
# 0| 3: [IntegerLiteral] 3
|
||||
# 27| 2: [Annotation] Ann1
|
||||
# 0| 1: [IntegerLiteral] 1
|
||||
# 0| 2: [Annotation] Ann2
|
||||
# 0| 1: [StringLiteral] "Hello"
|
||||
# 0| 2: [TypeLiteral] String.class
|
||||
# 0| 0: [TypeAccess] String
|
||||
# 0| 3: [ArrayInit] {...}
|
||||
# 0| 1: [IntegerLiteral] 1
|
||||
# 0| 2: [IntegerLiteral] 2
|
||||
# 0| 3: [IntegerLiteral] 3
|
||||
# 0| 4: [ArrayInit] {...}
|
||||
# 0| 1: [Annotation] Ann3
|
||||
# 0| 1: [IntegerLiteral] 1
|
||||
# 0| 2: [Annotation] Ann3
|
||||
# 0| 1: [IntegerLiteral] 2
|
||||
# 0| 5: [ArrayInit] {...}
|
||||
# 0| 1: [TypeLiteral] String.class
|
||||
# 0| 0: [TypeAccess] String
|
||||
# 0| 2: [TypeLiteral] int.class
|
||||
# 0| 0: [TypeAccess] int
|
||||
# 0| 3: [VarAccess] DayOfWeek.MONDAY
|
||||
# 0| -1: [TypeAccess] DayOfWeek
|
||||
# 28| 3: [Annotation] GenericAnnotation
|
||||
# 0| 1: [TypeLiteral] String.class
|
||||
# 0| 0: [TypeAccess] String
|
||||
# 0| 2: [ArrayInit] {...}
|
||||
# 0| 1: [TypeLiteral] String.class
|
||||
# 0| 0: [TypeAccess] String
|
||||
# 0| 2: [TypeLiteral] String.class
|
||||
# 0| 0: [TypeAccess] String
|
||||
# 34| 4: [Annotation] AnnWithDefaults
|
||||
# 0| 1: [IntegerLiteral] 1
|
||||
# 0| 2: [StringLiteral] "hello"
|
||||
# 0| 3: [VarAccess] DayOfWeek.TUESDAY
|
||||
# 0| -1: [TypeAccess] DayOfWeek
|
||||
# 0| 4: [ArrayInit] {...}
|
||||
# 0| 1: [Annotation] Ann3
|
||||
# 0| 1: [IntegerLiteral] 1
|
||||
# 35| 1: [Constructor] AnnotatedUsedByKotlin
|
||||
# 27| 5: [BlockStmt] { ... }
|
||||
# 27| 0: [SuperConstructorInvocationStmt] super(...)
|
||||
# 35| 1: [BlockStmt] { ... }
|
||||
# 37| 10: [Class] HasJavaDeprecatedAnnotationUsedByJava
|
||||
#-----| -3: (Annotations)
|
||||
# 37| 1: [Annotation] Deprecated
|
||||
# 38| 1: [Constructor] HasJavaDeprecatedAnnotationUsedByJava
|
||||
# 37| 5: [BlockStmt] { ... }
|
||||
# 37| 0: [SuperConstructorInvocationStmt] super(...)
|
||||
# 38| 1: [BlockStmt] { ... }
|
||||
# 40| 11: [Class] HasKotlinDeprecatedAnnotationUsedByJava
|
||||
#-----| -3: (Annotations)
|
||||
# 40| 1: [Annotation] Deprecated
|
||||
# 0| 1: [StringLiteral] "Kotlin deprecation message 1"
|
||||
# 41| 1: [Constructor] HasKotlinDeprecatedAnnotationUsedByJava
|
||||
# 40| 5: [BlockStmt] { ... }
|
||||
# 40| 0: [SuperConstructorInvocationStmt] super(...)
|
||||
# 41| 1: [BlockStmt] { ... }
|
||||
# 43| 12: [Class] HasJavaDeprecatedAnnotationUsedByKotlin
|
||||
#-----| -3: (Annotations)
|
||||
# 43| 1: [Annotation] Deprecated
|
||||
# 44| 1: [Constructor] HasJavaDeprecatedAnnotationUsedByKotlin
|
||||
# 43| 5: [BlockStmt] { ... }
|
||||
# 43| 0: [SuperConstructorInvocationStmt] super(...)
|
||||
# 44| 1: [BlockStmt] { ... }
|
||||
# 46| 13: [Class] HasKotlinDeprecatedAnnotationUsedByKotlin
|
||||
#-----| -3: (Annotations)
|
||||
# 46| 1: [Annotation] Deprecated
|
||||
# 0| 1: [StringLiteral] "Kotlin deprecation message 2"
|
||||
# 47| 1: [Constructor] HasKotlinDeprecatedAnnotationUsedByKotlin
|
||||
# 46| 5: [BlockStmt] { ... }
|
||||
# 46| 0: [SuperConstructorInvocationStmt] super(...)
|
||||
# 47| 1: [BlockStmt] { ... }
|
||||
@@ -0,0 +1 @@
|
||||
semmle/code/java/PrintAst.ql
|
||||
@@ -0,0 +1,7 @@
|
||||
public class User {
|
||||
|
||||
public static void user(Ann1 a1, Ann2 a2) {
|
||||
a1.x(); a2.z(); new Annotated(); new HasJavaDeprecatedAnnotationUsedByJava(); new HasKotlinDeprecatedAnnotationUsedByJava();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
| HasJavaDeprecatedAnnotationUsedByJava | java.lang.Deprecated |
|
||||
| HasJavaDeprecatedAnnotationUsedByKotlin | java.lang.Deprecated |
|
||||
| HasKotlinDeprecatedAnnotationUsedByJava | kotlin.Deprecated |
|
||||
| HasKotlinDeprecatedAnnotationUsedByKotlin | kotlin.Deprecated |
|
||||
| isJavaLetter | java.lang.Deprecated |
|
||||
@@ -0,0 +1,11 @@
|
||||
import java
|
||||
|
||||
from Annotatable a, Annotation ann
|
||||
where
|
||||
(
|
||||
a.(Method).hasQualifiedName("java.lang", "Character", "isJavaLetter") or
|
||||
a.(ClassOrInterface).fromSource()
|
||||
) and
|
||||
ann = a.getAnAnnotation() and
|
||||
ann.getType().getName() = "Deprecated"
|
||||
select a.toString(), a.getAnAnnotation().getType().getQualifiedName()
|
||||
@@ -0,0 +1,5 @@
|
||||
extensions:
|
||||
- addsTo:
|
||||
pack: integrationtest-annotation-id-consistency
|
||||
extensible: extNegativeSummaryModel
|
||||
data: []
|
||||
@@ -0,0 +1,11 @@
|
||||
public class KtUser {
|
||||
|
||||
fun user() {
|
||||
val a = AnnotatedUsedByKotlin()
|
||||
val b = HasJavaDeprecatedAnnotationUsedByKotlin()
|
||||
val c = HasKotlinDeprecatedAnnotationUsedByKotlin()
|
||||
// Use a Java-defined function carrying a java.lang.Deprecated annotation:
|
||||
java.lang.Character.isJavaLetter('a')
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
name: integrationtest-annotation-id-consistency
|
||||
dependencies:
|
||||
codeql/java-all: '*'
|
||||
codeql/java-tests: '*'
|
||||
codeql/java-queries: '*'
|
||||
dataExtensions:
|
||||
ext/*.model.yml
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
import kotlin.reflect.KClass
|
||||
import java.time.DayOfWeek
|
||||
|
||||
annotation class Ann1(val x: Int, val y: Ann2, val z: DayOfWeek) { }
|
||||
|
||||
annotation class Ann2(val z: String, val w: KClass<*>, val v: IntArray, val u: Array<Ann3>, val t: Array<KClass<*>>) { }
|
||||
|
||||
annotation class Ann3(val a: Int) { }
|
||||
|
||||
annotation class GenericAnnotation<T : Any>(val x: KClass<T>, val y: Array<KClass<T>>) { }
|
||||
|
||||
@Repeatable
|
||||
annotation class VarargAnnotation(vararg val x: Int) { }
|
||||
|
||||
annotation class AnnWithDefaults(val x: Int = 1, val y: String = "hello", val z: DayOfWeek = DayOfWeek.TUESDAY, val w: Array<Ann3> = [Ann3(1)]) { }
|
||||
|
||||
@Ann1(1, Ann2("Hello", String::class, intArrayOf(1, 2, 3), arrayOf(Ann3(1), Ann3(2)), arrayOf(String::class, Int::class)), DayOfWeek.MONDAY)
|
||||
@GenericAnnotation<String>(String::class, arrayOf(String::class, String::class))
|
||||
@VarargAnnotation
|
||||
@VarargAnnotation(1)
|
||||
@VarargAnnotation(1, 2)
|
||||
@VarargAnnotation(*[1, 2, 3])
|
||||
@VarargAnnotation(*intArrayOf(1, 2, 3))
|
||||
@AnnWithDefaults
|
||||
class Annotated { }
|
||||
|
||||
@Ann1(1, Ann2("Hello", String::class, intArrayOf(1, 2, 3), arrayOf(Ann3(1), Ann3(2)), arrayOf(String::class, Int::class)), DayOfWeek.MONDAY)
|
||||
@GenericAnnotation<String>(String::class, arrayOf(String::class, String::class))
|
||||
@VarargAnnotation
|
||||
@VarargAnnotation(1)
|
||||
@VarargAnnotation(1, 2)
|
||||
@VarargAnnotation(*[1, 2, 3])
|
||||
@VarargAnnotation(*intArrayOf(1, 2, 3))
|
||||
@AnnWithDefaults
|
||||
class AnnotatedUsedByKotlin { }
|
||||
|
||||
@java.lang.Deprecated
|
||||
class HasJavaDeprecatedAnnotationUsedByJava
|
||||
|
||||
@kotlin.Deprecated("Kotlin deprecation message 1")
|
||||
class HasKotlinDeprecatedAnnotationUsedByJava
|
||||
|
||||
@java.lang.Deprecated
|
||||
class HasJavaDeprecatedAnnotationUsedByKotlin
|
||||
|
||||
@kotlin.Deprecated("Kotlin deprecation message 2")
|
||||
class HasKotlinDeprecatedAnnotationUsedByKotlin
|
||||
@@ -0,0 +1,5 @@
|
||||
from create_database_utils import *
|
||||
|
||||
os.mkdir('out')
|
||||
os.mkdir('out2')
|
||||
run_codeql_database_create(["kotlinc test.kt -d out", "javac User.java -cp out -d out2", "kotlinc ktUser.kt -cp out -d out2"], lang="java")
|
||||
@@ -1,7 +1,17 @@
|
||||
app/src/main/kotlin/testProject/App.kt:
|
||||
# 0| [CompilationUnit] App
|
||||
# 7| 1: [Class] Project
|
||||
#-----| -3: (Annotations)
|
||||
# 7| 1: [Annotation] Serializable
|
||||
# 0| 1: [Constructor] Project
|
||||
#-----| 1: (Annotations)
|
||||
# 0| 1: [Annotation] Deprecated
|
||||
# 0| 1: [StringLiteral] "This synthesized declaration should not be used directly"
|
||||
# 0| 2: [Annotation] ReplaceWith
|
||||
# 0| 1: [StringLiteral] ""
|
||||
# 0| 2: [ArrayInit] {...}
|
||||
# 0| 3: [VarAccess] DeprecationLevel.HIDDEN
|
||||
# 0| -1: [TypeAccess] DeprecationLevel
|
||||
#-----| 4: (Parameters)
|
||||
# 0| 0: [Parameter] seen1
|
||||
# 0| 0: [TypeAccess] int
|
||||
@@ -41,6 +51,8 @@ app/src/main/kotlin/testProject/App.kt:
|
||||
# 7| 0: [TypeAccess] Project
|
||||
# 7| 1: [VarAccess] language
|
||||
# 0| 2: [Method] component1
|
||||
#-----| 1: (Annotations)
|
||||
# 0| 1: [Annotation] NotNull
|
||||
# 0| 3: [TypeAccess] String
|
||||
# 0| 5: [BlockStmt] { ... }
|
||||
# 0| 0: [ReturnStmt] return ...
|
||||
@@ -53,9 +65,13 @@ app/src/main/kotlin/testProject/App.kt:
|
||||
# 0| 0: [VarAccess] this.language
|
||||
# 0| -1: [ThisAccess] this
|
||||
# 0| 4: [Method] copy
|
||||
#-----| 1: (Annotations)
|
||||
# 0| 1: [Annotation] NotNull
|
||||
# 0| 3: [TypeAccess] Project
|
||||
#-----| 4: (Parameters)
|
||||
# 8| 0: [Parameter] name
|
||||
#-----| -1: (Annotations)
|
||||
# 0| 1: [Annotation] NotNull
|
||||
# 8| 0: [TypeAccess] String
|
||||
# 8| 1: [Parameter] language
|
||||
# 8| 0: [TypeAccess] int
|
||||
@@ -176,6 +192,8 @@ app/src/main/kotlin/testProject/App.kt:
|
||||
# 0| 2: [ReturnStmt] return ...
|
||||
# 0| 0: [VarAccess] result
|
||||
# 0| 8: [Method] toString
|
||||
#-----| 1: (Annotations)
|
||||
# 0| 1: [Annotation] NotNull
|
||||
# 0| 3: [TypeAccess] String
|
||||
# 0| 5: [BlockStmt] { ... }
|
||||
# 0| 0: [ReturnStmt] return ...
|
||||
@@ -190,13 +208,21 @@ app/src/main/kotlin/testProject/App.kt:
|
||||
# 0| -1: [ThisAccess] this
|
||||
# 0| 6: [StringLiteral] ")"
|
||||
# 0| 9: [Method] write$Self
|
||||
#-----| 1: (Annotations)
|
||||
# 0| 1: [Annotation] JvmStatic
|
||||
# 0| 3: [TypeAccess] Unit
|
||||
#-----| 4: (Parameters)
|
||||
# 0| 0: [Parameter] self
|
||||
#-----| -1: (Annotations)
|
||||
# 0| 1: [Annotation] NotNull
|
||||
# 0| 0: [TypeAccess] Project
|
||||
# 0| 1: [Parameter] output
|
||||
#-----| -1: (Annotations)
|
||||
# 0| 1: [Annotation] NotNull
|
||||
# 0| 0: [TypeAccess] CompositeEncoder
|
||||
# 0| 2: [Parameter] serialDesc
|
||||
#-----| -1: (Annotations)
|
||||
# 0| 1: [Annotation] NotNull
|
||||
# 0| 0: [TypeAccess] SerialDescriptor
|
||||
# 7| 5: [BlockStmt] { ... }
|
||||
# 7| 0: [ExprStmt] <Expr>;
|
||||
@@ -214,9 +240,19 @@ app/src/main/kotlin/testProject/App.kt:
|
||||
# 7| 2: [MethodAccess] getLanguage(...)
|
||||
# 7| -1: [VarAccess] self
|
||||
# 7| 10: [Class] $serializer
|
||||
#-----| -3: (Annotations)
|
||||
# 0| 1: [Annotation] Deprecated
|
||||
# 0| 1: [StringLiteral] "This synthesized declaration should not be used directly"
|
||||
# 0| 2: [Annotation] ReplaceWith
|
||||
# 0| 1: [StringLiteral] ""
|
||||
# 0| 2: [ArrayInit] {...}
|
||||
# 0| 3: [VarAccess] DeprecationLevel.HIDDEN
|
||||
# 0| -1: [TypeAccess] DeprecationLevel
|
||||
# 0| 1: [FieldDeclaration] SerialDescriptor descriptor;
|
||||
# 0| -1: [TypeAccess] SerialDescriptor
|
||||
# 0| 2: [Method] childSerializers
|
||||
#-----| 1: (Annotations)
|
||||
# 0| 1: [Annotation] NotNull
|
||||
# 0| 3: [TypeAccess] KSerializer<?>[]
|
||||
# 0| 0: [TypeAccess] KSerializer<?>
|
||||
# 0| 0: [WildcardTypeAccess] ? ...
|
||||
@@ -227,9 +263,13 @@ app/src/main/kotlin/testProject/App.kt:
|
||||
# 7| -1: [TypeAccess] KSerializer<?>
|
||||
# 7| 0: [IntegerLiteral] 2
|
||||
# 0| 3: [Method] deserialize
|
||||
#-----| 1: (Annotations)
|
||||
# 0| 1: [Annotation] NotNull
|
||||
# 0| 3: [TypeAccess] Project
|
||||
#-----| 4: (Parameters)
|
||||
# 0| 0: [Parameter] decoder
|
||||
#-----| -1: (Annotations)
|
||||
# 0| 1: [Annotation] NotNull
|
||||
# 0| 0: [TypeAccess] Decoder
|
||||
# 7| 5: [BlockStmt] { ... }
|
||||
# 7| 0: [LocalVariableDeclStmt] var ...;
|
||||
@@ -365,6 +405,8 @@ app/src/main/kotlin/testProject/App.kt:
|
||||
# 7| 2: [VarAccess] tmp5_local1
|
||||
# 7| 3: [NullLiteral] null
|
||||
# 0| 4: [Method] getDescriptor
|
||||
#-----| 1: (Annotations)
|
||||
# 0| 1: [Annotation] NotNull
|
||||
# 0| 3: [TypeAccess] SerialDescriptor
|
||||
# 0| 5: [BlockStmt] { ... }
|
||||
# 0| 0: [ReturnStmt] return ...
|
||||
@@ -374,8 +416,12 @@ app/src/main/kotlin/testProject/App.kt:
|
||||
# 0| 3: [TypeAccess] Unit
|
||||
#-----| 4: (Parameters)
|
||||
# 0| 0: [Parameter] encoder
|
||||
#-----| -1: (Annotations)
|
||||
# 0| 1: [Annotation] NotNull
|
||||
# 0| 0: [TypeAccess] Encoder
|
||||
# 0| 1: [Parameter] value
|
||||
#-----| -1: (Annotations)
|
||||
# 0| 1: [Annotation] NotNull
|
||||
# 0| 0: [TypeAccess] Project
|
||||
# 7| 5: [BlockStmt] { ... }
|
||||
# 7| 0: [LocalVariableDeclStmt] var ...;
|
||||
@@ -436,6 +482,8 @@ app/src/main/kotlin/testProject/App.kt:
|
||||
# 7| 0: [TypeAccess] GeneratedSerializer
|
||||
# 7| 11: [Class] Companion
|
||||
# 0| 1: [Method] serializer
|
||||
#-----| 1: (Annotations)
|
||||
# 0| 1: [Annotation] NotNull
|
||||
# 0| 3: [TypeAccess] KSerializer<Project>
|
||||
# 0| 0: [TypeAccess] Project
|
||||
# 7| 5: [BlockStmt] { ... }
|
||||
@@ -448,6 +496,8 @@ app/src/main/kotlin/testProject/App.kt:
|
||||
# 8| 12: [Constructor] Project
|
||||
#-----| 4: (Parameters)
|
||||
# 8| 0: [Parameter] name
|
||||
#-----| -1: (Annotations)
|
||||
# 0| 1: [Annotation] NotNull
|
||||
# 8| 0: [TypeAccess] String
|
||||
# 8| 1: [Parameter] language
|
||||
# 8| 0: [TypeAccess] int
|
||||
@@ -464,6 +514,8 @@ app/src/main/kotlin/testProject/App.kt:
|
||||
# 8| -1: [TypeAccess] String
|
||||
# 8| 0: [VarAccess] name
|
||||
# 8| 14: [Method] getName
|
||||
#-----| 1: (Annotations)
|
||||
# 0| 1: [Annotation] NotNull
|
||||
# 8| 3: [TypeAccess] String
|
||||
# 8| 5: [BlockStmt] { ... }
|
||||
# 8| 0: [ReturnStmt] return ...
|
||||
@@ -480,9 +532,21 @@ app/src/main/kotlin/testProject/App.kt:
|
||||
# 8| 0: [VarAccess] language
|
||||
# 10| 2: [Interface] Base
|
||||
# 11| 1: [Method] getId
|
||||
#-----| 1: (Annotations)
|
||||
# 0| 1: [Annotation] NotNull
|
||||
# 11| 3: [TypeAccess] String
|
||||
# 14| 3: [Class] X
|
||||
#-----| -3: (Annotations)
|
||||
# 14| 1: [Annotation] Serializable
|
||||
# 0| 1: [Constructor] X
|
||||
#-----| 1: (Annotations)
|
||||
# 0| 1: [Annotation] Deprecated
|
||||
# 0| 1: [StringLiteral] "This synthesized declaration should not be used directly"
|
||||
# 0| 2: [Annotation] ReplaceWith
|
||||
# 0| 1: [StringLiteral] ""
|
||||
# 0| 2: [ArrayInit] {...}
|
||||
# 0| 3: [VarAccess] DeprecationLevel.HIDDEN
|
||||
# 0| -1: [TypeAccess] DeprecationLevel
|
||||
#-----| 4: (Parameters)
|
||||
# 0| 0: [Parameter] seen1
|
||||
# 0| 0: [TypeAccess] int
|
||||
@@ -530,13 +594,21 @@ app/src/main/kotlin/testProject/App.kt:
|
||||
# 14| 0: [TypeAccess] X
|
||||
# 14| 1: [VarAccess] id
|
||||
# 0| 2: [Method] write$Self
|
||||
#-----| 1: (Annotations)
|
||||
# 0| 1: [Annotation] JvmStatic
|
||||
# 0| 3: [TypeAccess] Unit
|
||||
#-----| 4: (Parameters)
|
||||
# 0| 0: [Parameter] self
|
||||
#-----| -1: (Annotations)
|
||||
# 0| 1: [Annotation] NotNull
|
||||
# 0| 0: [TypeAccess] X
|
||||
# 0| 1: [Parameter] output
|
||||
#-----| -1: (Annotations)
|
||||
# 0| 1: [Annotation] NotNull
|
||||
# 0| 0: [TypeAccess] CompositeEncoder
|
||||
# 0| 2: [Parameter] serialDesc
|
||||
#-----| -1: (Annotations)
|
||||
# 0| 1: [Annotation] NotNull
|
||||
# 0| 0: [TypeAccess] SerialDescriptor
|
||||
# 14| 5: [BlockStmt] { ... }
|
||||
# 14| 0: [ExprStmt] <Expr>;
|
||||
@@ -565,9 +637,19 @@ app/src/main/kotlin/testProject/App.kt:
|
||||
# 14| 2: [MethodAccess] getId(...)
|
||||
# 14| -1: [VarAccess] self
|
||||
# 14| 3: [Class] $serializer
|
||||
#-----| -3: (Annotations)
|
||||
# 0| 1: [Annotation] Deprecated
|
||||
# 0| 1: [StringLiteral] "This synthesized declaration should not be used directly"
|
||||
# 0| 2: [Annotation] ReplaceWith
|
||||
# 0| 1: [StringLiteral] ""
|
||||
# 0| 2: [ArrayInit] {...}
|
||||
# 0| 3: [VarAccess] DeprecationLevel.HIDDEN
|
||||
# 0| -1: [TypeAccess] DeprecationLevel
|
||||
# 0| 1: [FieldDeclaration] SerialDescriptor descriptor;
|
||||
# 0| -1: [TypeAccess] SerialDescriptor
|
||||
# 0| 2: [Method] childSerializers
|
||||
#-----| 1: (Annotations)
|
||||
# 0| 1: [Annotation] NotNull
|
||||
# 0| 3: [TypeAccess] KSerializer<?>[]
|
||||
# 0| 0: [TypeAccess] KSerializer<?>
|
||||
# 0| 0: [WildcardTypeAccess] ? ...
|
||||
@@ -578,9 +660,13 @@ app/src/main/kotlin/testProject/App.kt:
|
||||
# 14| -1: [TypeAccess] KSerializer<?>
|
||||
# 14| 0: [IntegerLiteral] 1
|
||||
# 0| 3: [Method] deserialize
|
||||
#-----| 1: (Annotations)
|
||||
# 0| 1: [Annotation] NotNull
|
||||
# 0| 3: [TypeAccess] X
|
||||
#-----| 4: (Parameters)
|
||||
# 0| 0: [Parameter] decoder
|
||||
#-----| -1: (Annotations)
|
||||
# 0| 1: [Annotation] NotNull
|
||||
# 0| 0: [TypeAccess] Decoder
|
||||
# 14| 5: [BlockStmt] { ... }
|
||||
# 14| 0: [LocalVariableDeclStmt] var ...;
|
||||
@@ -680,6 +766,8 @@ app/src/main/kotlin/testProject/App.kt:
|
||||
# 14| 1: [VarAccess] tmp4_local0
|
||||
# 14| 2: [NullLiteral] null
|
||||
# 0| 4: [Method] getDescriptor
|
||||
#-----| 1: (Annotations)
|
||||
# 0| 1: [Annotation] NotNull
|
||||
# 0| 3: [TypeAccess] SerialDescriptor
|
||||
# 0| 5: [BlockStmt] { ... }
|
||||
# 0| 0: [ReturnStmt] return ...
|
||||
@@ -689,8 +777,12 @@ app/src/main/kotlin/testProject/App.kt:
|
||||
# 0| 3: [TypeAccess] Unit
|
||||
#-----| 4: (Parameters)
|
||||
# 0| 0: [Parameter] encoder
|
||||
#-----| -1: (Annotations)
|
||||
# 0| 1: [Annotation] NotNull
|
||||
# 0| 0: [TypeAccess] Encoder
|
||||
# 0| 1: [Parameter] value
|
||||
#-----| -1: (Annotations)
|
||||
# 0| 1: [Annotation] NotNull
|
||||
# 0| 0: [TypeAccess] X
|
||||
# 14| 5: [BlockStmt] { ... }
|
||||
# 14| 0: [LocalVariableDeclStmt] var ...;
|
||||
@@ -746,6 +838,8 @@ app/src/main/kotlin/testProject/App.kt:
|
||||
# 14| 0: [TypeAccess] GeneratedSerializer
|
||||
# 14| 4: [Class] Companion
|
||||
# 0| 1: [Method] serializer
|
||||
#-----| 1: (Annotations)
|
||||
# 0| 1: [Annotation] NotNull
|
||||
# 0| 3: [TypeAccess] KSerializer<X>
|
||||
# 0| 0: [TypeAccess] X
|
||||
# 14| 5: [BlockStmt] { ... }
|
||||
@@ -766,6 +860,8 @@ app/src/main/kotlin/testProject/App.kt:
|
||||
# 16| -1: [TypeAccess] String
|
||||
# 16| 0: [StringLiteral] "X"
|
||||
# 16| 7: [Method] getId
|
||||
#-----| 1: (Annotations)
|
||||
# 0| 1: [Annotation] NotNull
|
||||
# 16| 3: [TypeAccess] String
|
||||
# 16| 5: [BlockStmt] { ... }
|
||||
# 16| 0: [ReturnStmt] return ...
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
import org.jetbrains.annotations.*;
|
||||
import zpkg.A;
|
||||
|
||||
public interface AnnotatedInterface {
|
||||
|
||||
public @A @NotNull String notNullAnnotated(@A @NotNull String param);
|
||||
|
||||
public @A @Nullable String nullableAnnotated(@A @Nullable String param);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import org.jetbrains.annotations.*;
|
||||
import zpkg.A;
|
||||
|
||||
public class AnnotatedMethods implements AnnotatedInterface {
|
||||
|
||||
public @A @NotNull String notNullAnnotated(@A @NotNull String param) { return param; }
|
||||
|
||||
public @A @Nullable String nullableAnnotated(@A @Nullable String param) { return param; }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
public class JavaUser {
|
||||
|
||||
public static void test(KotlinAnnotatedMethods km, KotlinDelegate kd) {
|
||||
km.f(null);
|
||||
kd.notNullAnnotated("Hello world");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import zpkg.A
|
||||
|
||||
class KotlinAnnotatedMethods {
|
||||
|
||||
@A fun f(@A m: AnnotatedMethods): String = m.notNullAnnotated("hello") + m.nullableAnnotated("world")!!
|
||||
|
||||
}
|
||||
|
||||
class KotlinDelegate(c: AnnotatedMethods) : AnnotatedInterface by c { }
|
||||
@@ -0,0 +1,6 @@
|
||||
package org.jetbrains.annotations;
|
||||
|
||||
public @interface NotNull {
|
||||
String value() default "";
|
||||
Class<? extends Exception> exception() default Exception.class;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package org.jetbrains.annotations;
|
||||
|
||||
public @interface Nullable {
|
||||
String value() default "";
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
| AnnotatedInterface.java:6:29:6:44 | notNullAnnotated | parameter | AnnotatedInterface.java:6:46:6:47 | A |
|
||||
| AnnotatedInterface.java:6:29:6:44 | notNullAnnotated | parameter | AnnotatedInterface.java:6:49:6:56 | NotNull |
|
||||
| AnnotatedInterface.java:6:29:6:44 | notNullAnnotated | return value | AnnotatedInterface.java:6:10:6:11 | A |
|
||||
| AnnotatedInterface.java:6:29:6:44 | notNullAnnotated | return value | AnnotatedInterface.java:6:13:6:20 | NotNull |
|
||||
| AnnotatedInterface.java:8:30:8:46 | nullableAnnotated | parameter | AnnotatedInterface.java:8:48:8:49 | A |
|
||||
| AnnotatedInterface.java:8:30:8:46 | nullableAnnotated | parameter | AnnotatedInterface.java:8:51:8:59 | Nullable |
|
||||
| AnnotatedInterface.java:8:30:8:46 | nullableAnnotated | return value | AnnotatedInterface.java:8:10:8:11 | A |
|
||||
| AnnotatedInterface.java:8:30:8:46 | nullableAnnotated | return value | AnnotatedInterface.java:8:13:8:21 | Nullable |
|
||||
| AnnotatedMethods.java:6:29:6:44 | notNullAnnotated | parameter | AnnotatedMethods.java:6:46:6:47 | A |
|
||||
| AnnotatedMethods.java:6:29:6:44 | notNullAnnotated | parameter | AnnotatedMethods.java:6:49:6:56 | NotNull |
|
||||
| AnnotatedMethods.java:6:29:6:44 | notNullAnnotated | return value | AnnotatedMethods.java:6:10:6:11 | A |
|
||||
| AnnotatedMethods.java:6:29:6:44 | notNullAnnotated | return value | AnnotatedMethods.java:6:13:6:20 | NotNull |
|
||||
| AnnotatedMethods.java:8:30:8:46 | nullableAnnotated | parameter | AnnotatedMethods.java:8:48:8:49 | A |
|
||||
| AnnotatedMethods.java:8:30:8:46 | nullableAnnotated | parameter | AnnotatedMethods.java:8:51:8:59 | Nullable |
|
||||
| AnnotatedMethods.java:8:30:8:46 | nullableAnnotated | return value | AnnotatedMethods.java:8:10:8:11 | A |
|
||||
| AnnotatedMethods.java:8:30:8:46 | nullableAnnotated | return value | AnnotatedMethods.java:8:13:8:21 | Nullable |
|
||||
| ktUser.kt:0:0:0:0 | notNullAnnotated | parameter | ktUser.kt:0:0:0:0 | A |
|
||||
| ktUser.kt:0:0:0:0 | notNullAnnotated | parameter | ktUser.kt:0:0:0:0 | NotNull |
|
||||
| ktUser.kt:0:0:0:0 | notNullAnnotated | return value | ktUser.kt:0:0:0:0 | A |
|
||||
| ktUser.kt:0:0:0:0 | notNullAnnotated | return value | ktUser.kt:0:0:0:0 | NotNull |
|
||||
| ktUser.kt:0:0:0:0 | nullableAnnotated | parameter | ktUser.kt:0:0:0:0 | A |
|
||||
| ktUser.kt:0:0:0:0 | nullableAnnotated | parameter | ktUser.kt:0:0:0:0 | Nullable |
|
||||
| ktUser.kt:0:0:0:0 | nullableAnnotated | return value | ktUser.kt:0:0:0:0 | A |
|
||||
| ktUser.kt:0:0:0:0 | nullableAnnotated | return value | ktUser.kt:0:0:0:0 | Nullable |
|
||||
| ktUser.kt:5:6:5:105 | f | parameter | ktUser.kt:0:0:0:0 | NotNull |
|
||||
| ktUser.kt:5:6:5:105 | f | parameter | ktUser.kt:5:12:5:13 | A |
|
||||
| ktUser.kt:5:6:5:105 | f | return value | ktUser.kt:0:0:0:0 | NotNull |
|
||||
| ktUser.kt:5:6:5:105 | f | return value | ktUser.kt:5:3:5:4 | A |
|
||||
@@ -0,0 +1,7 @@
|
||||
from create_database_utils import *
|
||||
import os
|
||||
|
||||
os.mkdir('out')
|
||||
os.mkdir('out2')
|
||||
os.mkdir('out3')
|
||||
run_codeql_database_create(["javac AnnotatedInterface.java AnnotatedMethods.java zpkg/A.java org/jetbrains/annotations/NotNull.java org/jetbrains/annotations/Nullable.java -d out", "kotlinc ktUser.kt -cp out -d out2", "javac JavaUser.java -cp out" + os.pathsep + "out2 -d out3"], lang="java")
|
||||
@@ -0,0 +1,11 @@
|
||||
import java
|
||||
|
||||
from Method m, string origin, Annotation a
|
||||
where
|
||||
m.fromSource() and
|
||||
(
|
||||
origin = "return value" and a = m.getAnAnnotation()
|
||||
or
|
||||
origin = "parameter" and a = m.getAParameter().getAnAnnotation()
|
||||
)
|
||||
select m, origin, a
|
||||
@@ -0,0 +1,3 @@
|
||||
package zpkg;
|
||||
|
||||
public @interface A { }
|
||||
@@ -0,0 +1,5 @@
|
||||
public @interface JavaDefinedContainer {
|
||||
|
||||
public JavaDefinedRepeatable[] value();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
@java.lang.annotation.Repeatable(JavaDefinedContainer.class)
|
||||
public @interface JavaDefinedRepeatable { }
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
@LocalRepeatable
|
||||
@LocalRepeatable
|
||||
@LibRepeatable
|
||||
@LibRepeatable
|
||||
@ExplicitContainerRepeatable
|
||||
@ExplicitContainerRepeatable
|
||||
@JavaDefinedRepeatable
|
||||
@JavaDefinedRepeatable
|
||||
public class JavaUser { }
|
||||
@@ -0,0 +1,7 @@
|
||||
@Repeatable
|
||||
public annotation class LibRepeatable { }
|
||||
|
||||
annotation class KtDefinedContainer(val value: Array<ExplicitContainerRepeatable>) { }
|
||||
|
||||
@java.lang.annotation.Repeatable(KtDefinedContainer::class)
|
||||
annotation class ExplicitContainerRepeatable() { }
|
||||
@@ -0,0 +1,16 @@
|
||||
| JavaUser.java:9:14:9:21 | JavaUser | out2/JavaUser.class:0:0:0:0 | Container | value | out2/JavaUser.class:0:0:0:0 | {...} |
|
||||
| JavaUser.java:9:14:9:21 | JavaUser | out2/JavaUser.class:0:0:0:0 | Container | value | out2/JavaUser.class:0:0:0:0 | {...} |
|
||||
| JavaUser.java:9:14:9:21 | JavaUser | out2/JavaUser.class:0:0:0:0 | JavaDefinedContainer | value | out2/JavaUser.class:0:0:0:0 | {...} |
|
||||
| JavaUser.java:9:14:9:21 | JavaUser | out2/JavaUser.class:0:0:0:0 | KtDefinedContainer | value | out2/JavaUser.class:0:0:0:0 | {...} |
|
||||
| out/ExplicitContainerRepeatable.class:0:0:0:0 | ExplicitContainerRepeatable | out/ExplicitContainerRepeatable.class:0:0:0:0 | Repeatable | value | out/ExplicitContainerRepeatable.class:0:0:0:0 | KtDefinedContainer.class |
|
||||
| out/ExplicitContainerRepeatable.class:0:0:0:0 | ExplicitContainerRepeatable | out/ExplicitContainerRepeatable.class:0:0:0:0 | Retention | value | out/ExplicitContainerRepeatable.class:0:0:0:0 | RUNTIME |
|
||||
| out/JavaDefinedRepeatable.class:0:0:0:0 | JavaDefinedRepeatable | out/JavaDefinedRepeatable.class:0:0:0:0 | Repeatable | value | out/JavaDefinedRepeatable.class:0:0:0:0 | JavaDefinedContainer.class |
|
||||
| out/KtDefinedContainer.class:0:0:0:0 | KtDefinedContainer | out/KtDefinedContainer.class:0:0:0:0 | Retention | value | out/KtDefinedContainer.class:0:0:0:0 | RUNTIME |
|
||||
| out/LibRepeatable.class:0:0:0:0 | LibRepeatable | out/LibRepeatable.class:0:0:0:0 | Repeatable | value | out/LibRepeatable.class:0:0:0:0 | Container.class |
|
||||
| out/LibRepeatable.class:0:0:0:0 | LibRepeatable | out/LibRepeatable.class:0:0:0:0 | Retention | value | out/LibRepeatable.class:0:0:0:0 | RUNTIME |
|
||||
| test.kt:1:1:2:43 | LocalRepeatable | test.kt:0:0:0:0 | Repeatable | value | test.kt:0:0:0:0 | Container.class |
|
||||
| test.kt:1:1:2:43 | LocalRepeatable | test.kt:0:0:0:0 | Retention | value | test.kt:0:0:0:0 | RetentionPolicy.RUNTIME |
|
||||
| test.kt:4:1:12:21 | User | test.kt:0:0:0:0 | Container | value | test.kt:0:0:0:0 | {...} |
|
||||
| test.kt:4:1:12:21 | User | test.kt:0:0:0:0 | Container | value | test.kt:0:0:0:0 | {...} |
|
||||
| test.kt:4:1:12:21 | User | test.kt:0:0:0:0 | JavaDefinedContainer | value | test.kt:0:0:0:0 | {...} |
|
||||
| test.kt:4:1:12:21 | User | test.kt:0:0:0:0 | KtDefinedContainer | value | test.kt:0:0:0:0 | {...} |
|
||||
@@ -0,0 +1,12 @@
|
||||
@Repeatable
|
||||
public annotation class LocalRepeatable { }
|
||||
|
||||
@LocalRepeatable
|
||||
@LocalRepeatable
|
||||
@LibRepeatable
|
||||
@LibRepeatable
|
||||
@ExplicitContainerRepeatable
|
||||
@ExplicitContainerRepeatable
|
||||
@JavaDefinedRepeatable
|
||||
@JavaDefinedRepeatable
|
||||
public class User { }
|
||||
@@ -0,0 +1,7 @@
|
||||
from create_database_utils import *
|
||||
|
||||
os.mkdir('out')
|
||||
os.mkdir('out2')
|
||||
runSuccessfully([get_cmd("kotlinc"), "lib.kt", "-d", "out"])
|
||||
runSuccessfully([get_cmd("javac"), "JavaDefinedContainer.java", "JavaDefinedRepeatable.java", "-d", "out"])
|
||||
run_codeql_database_create(["kotlinc test.kt -cp out -d out", "javac JavaUser.java -cp out -d out2"], lang="java")
|
||||
@@ -0,0 +1,11 @@
|
||||
import java
|
||||
|
||||
from ClassOrInterface annotated, Annotation a, string valName, Expr val
|
||||
where
|
||||
a.getValue(valName) = val and
|
||||
annotated = a.getAnnotatedElement() and
|
||||
annotated.getName() in [
|
||||
"JavaDefinedRepeatable", "JavaDefinedContainer", "KtDefinedContainer", "LibRepeatable",
|
||||
"ExplicitContainerRepeatable", "LocalRepeatable", "User", "JavaUser"
|
||||
]
|
||||
select a.getAnnotatedElement(), a, valName, val
|
||||
@@ -14,5 +14,5 @@ extensions:
|
||||
data: []
|
||||
- addsTo:
|
||||
pack: codeql/java-all
|
||||
extensible: extNegativeSummaryModel
|
||||
extensible: extNeutralModel
|
||||
data: []
|
||||
@@ -1861,7 +1861,7 @@ extensions:
|
||||
|
||||
- addsTo:
|
||||
pack: codeql/java-all
|
||||
extensible: extNegativeSummaryModel
|
||||
extensible: extNeutralModel
|
||||
data:
|
||||
- ["kotlin.annotation", "AnnotationRetention", "valueOf", "(String)", "generated"]
|
||||
- ["kotlin.annotation", "AnnotationRetention", "values", "()", "generated"]
|
||||
|
||||
@@ -676,7 +676,7 @@ extensions:
|
||||
|
||||
- addsTo:
|
||||
pack: codeql/java-all
|
||||
extensible: extNegativeSummaryModel
|
||||
extensible: extNeutralModel
|
||||
data:
|
||||
- ["org.apache.commons.io.charset", "CharsetDecoders", "CharsetDecoders", "()", "generated"]
|
||||
- ["org.apache.commons.io.charset", "CharsetEncoders", "CharsetEncoders", "()", "generated"]
|
||||
|
||||
@@ -37,7 +37,9 @@ class Annotation extends @annotation, Expr {
|
||||
}
|
||||
|
||||
/** Gets the annotation type declaration for this annotation. */
|
||||
override AnnotationType getType() { result = Expr.super.getType() }
|
||||
override AnnotationType getType() {
|
||||
result = Expr.super.getType().(Interface).getSourceDeclaration()
|
||||
}
|
||||
|
||||
/** Gets the annotation element with the specified `name`. */
|
||||
AnnotationElement getAnnotationElement(string name) {
|
||||
@@ -249,7 +251,7 @@ private predicate filteredAnnotValue(Annotation a, Method m, Expr val) {
|
||||
|
||||
private predicate sourceAnnotValue(Annotation a, Method m, Expr val) {
|
||||
annotValue(a, m, val) and
|
||||
val.getFile().getExtension() = "java"
|
||||
val.getFile().isSourceFile()
|
||||
}
|
||||
|
||||
/** An abstract representation of language elements that can be annotated. */
|
||||
|
||||
@@ -91,7 +91,7 @@ predicate numDepends(RefType t, RefType dep, int value) {
|
||||
elem = a and usesType(a.getType(), dep)
|
||||
or
|
||||
elem = [a.getValue(_), a.getAnArrayValue(_)] and
|
||||
elem.getFile().getExtension() = "java" and
|
||||
elem.getFile().isSourceFile() and
|
||||
usesType(elem.(Expr).getType(), dep)
|
||||
)
|
||||
or
|
||||
|
||||
@@ -120,7 +120,12 @@ private newtype TPrintAstNode =
|
||||
shouldPrint(lvde, _) and lvde.getParent() instanceof SingleLocalVarDeclParent
|
||||
} or
|
||||
TAnnotationsNode(Annotatable ann) {
|
||||
shouldPrint(ann, _) and ann.hasDeclaredAnnotation() and not partOfAnnotation(ann)
|
||||
shouldPrint(ann, _) and
|
||||
ann.hasDeclaredAnnotation() and
|
||||
not partOfAnnotation(ann) and
|
||||
// The Kotlin compiler might add annotations that are only present in byte code, although the annotatable element is
|
||||
// present in source code.
|
||||
exists(Annotation a | a.getAnnotatedElement() = ann and shouldPrint(a, _))
|
||||
} or
|
||||
TParametersNode(Callable c) { shouldPrint(c, _) and not c.hasNoParameters() } or
|
||||
TBaseTypesNode(ClassOrInterface ty) { shouldPrint(ty, _) } or
|
||||
@@ -293,19 +298,21 @@ final class AnnotationPartNode extends ExprStmtNode {
|
||||
|
||||
override ElementNode getChild(int childIndex) {
|
||||
result.getElement() =
|
||||
rank[childIndex](Element ch, string file, int line, int column |
|
||||
ch = this.getAnAnnotationChild() and locationSortKeys(ch, file, line, column)
|
||||
rank[childIndex](Element ch, string file, int line, int column, int idx |
|
||||
ch = this.getAnnotationChild(idx) and locationSortKeys(ch, file, line, column)
|
||||
|
|
||||
ch order by file, line, column
|
||||
ch order by file, line, column, idx
|
||||
)
|
||||
}
|
||||
|
||||
private Expr getAnAnnotationChild() {
|
||||
result = element.(Annotation).getValue(_)
|
||||
private Expr getAnnotationChild(int index) {
|
||||
result = element.(Annotation).getValue(_) and
|
||||
index >= 0 and
|
||||
if exists(int x | x >= 0 | result.isNthChildOf(element, x))
|
||||
then result.isNthChildOf(element, index)
|
||||
else result.isNthChildOf(element, -(index + 1))
|
||||
or
|
||||
result = element.(ArrayInit).getAnInit()
|
||||
or
|
||||
result = element.(ArrayInit).(Annotatable).getAnAnnotation()
|
||||
result = element.(ArrayInit).getInit(index)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -672,10 +679,10 @@ final class AnnotationsNode extends PrintAstNode, TAnnotationsNode {
|
||||
|
||||
override ElementNode getChild(int childIndex) {
|
||||
result.getElement() =
|
||||
rank[childIndex](Element e, string file, int line, int column |
|
||||
e = ann.getAnAnnotation() and locationSortKeys(e, file, line, column)
|
||||
rank[childIndex](Element e, string file, int line, int column, string s |
|
||||
e = ann.getAnAnnotation() and locationSortKeys(e, file, line, column) and s = e.toString()
|
||||
|
|
||||
e order by file, line, column
|
||||
e order by file, line, column, s
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -11,9 +11,9 @@
|
||||
* `package; type; subtypes; name; signature; ext; input; kind; provenance`
|
||||
* - Summaries:
|
||||
* `package; type; subtypes; name; signature; ext; input; output; kind; provenance`
|
||||
* - Negative Summaries:
|
||||
* - Neutrals:
|
||||
* `package; type; name; signature; provenance`
|
||||
* A negative summary is used to indicate that there is no flow via a callable.
|
||||
* A neutral is used to indicate that there is no flow via a callable.
|
||||
*
|
||||
* The interpretation of a row is similar to API-graphs with a left-to-right
|
||||
* reading.
|
||||
@@ -122,30 +122,12 @@ private class SummaryModelCsvInternal extends Unit {
|
||||
abstract predicate row(string row);
|
||||
}
|
||||
|
||||
/**
|
||||
* DEPRECATED: Define negative summary models as data extensions instead.
|
||||
*
|
||||
* A unit class for adding additional negative summary model rows.
|
||||
*
|
||||
* Extend this class to add additional negative summary definitions.
|
||||
*/
|
||||
deprecated class NegativeSummaryModelCsv = NegativeSummaryModelCsvInternal;
|
||||
|
||||
private class NegativeSummaryModelCsvInternal extends Unit {
|
||||
/** Holds if `row` specifies a negative summary definition. */
|
||||
abstract predicate row(string row);
|
||||
}
|
||||
|
||||
private predicate sourceModelInternal(string row) { any(SourceModelCsvInternal s).row(row) }
|
||||
|
||||
private predicate summaryModelInternal(string row) { any(SummaryModelCsvInternal s).row(row) }
|
||||
|
||||
private predicate sinkModelInternal(string row) { any(SinkModelCsvInternal s).row(row) }
|
||||
|
||||
private predicate negativeSummaryModelInternal(string row) {
|
||||
any(NegativeSummaryModelCsvInternal s).row(row)
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if an experimental source model exists for the given parameters.
|
||||
* This is only for experimental queries.
|
||||
@@ -313,25 +295,14 @@ predicate summaryModel(
|
||||
.summaryModel(package, type, subtypes, name, signature, ext, input, output, kind, provenance)
|
||||
}
|
||||
|
||||
/** Holds if a summary model exists indicating there is no flow for the given parameters. */
|
||||
extensible predicate extNegativeSummaryModel(
|
||||
/** Holds if a neutral model exists indicating there is no flow for the given parameters. */
|
||||
extensible predicate extNeutralModel(
|
||||
string package, string type, string name, string signature, string provenance
|
||||
);
|
||||
|
||||
/** Holds if a summary model exists indicating there is no flow for the given parameters. */
|
||||
predicate negativeSummaryModel(
|
||||
string package, string type, string name, string signature, string provenance
|
||||
) {
|
||||
exists(string row |
|
||||
negativeSummaryModelInternal(row) and
|
||||
row.splitAt(";", 0) = package and
|
||||
row.splitAt(";", 1) = type and
|
||||
row.splitAt(";", 2) = name and
|
||||
row.splitAt(";", 3) = signature and
|
||||
row.splitAt(";", 4) = provenance
|
||||
)
|
||||
or
|
||||
extNegativeSummaryModel(package, type, name, signature, provenance)
|
||||
/** Holds if a neutral model exists indicating there is no flow for the given parameters. */
|
||||
predicate neutralModel(string package, string type, string name, string signature, string provenance) {
|
||||
extNeutralModel(package, type, name, signature, provenance)
|
||||
}
|
||||
|
||||
private predicate relevantPackage(string package) {
|
||||
@@ -472,8 +443,6 @@ module ModelValidation {
|
||||
sinkModelInternal(row) and expect = 9 and pred = "sink"
|
||||
or
|
||||
summaryModelInternal(row) and expect = 10 and pred = "summary"
|
||||
or
|
||||
negativeSummaryModelInternal(row) and expect = 5 and pred = "negative summary"
|
||||
|
|
||||
exists(int cols |
|
||||
cols = 1 + max(int n | exists(row.splitAt(";", n))) and
|
||||
@@ -497,9 +466,9 @@ module ModelValidation {
|
||||
summaryModel(package, type, _, name, signature, ext, _, _, _, provenance) and
|
||||
pred = "summary"
|
||||
or
|
||||
negativeSummaryModel(package, type, name, signature, provenance) and
|
||||
neutralModel(package, type, name, signature, provenance) and
|
||||
ext = "" and
|
||||
pred = "negative summary"
|
||||
pred = "neutral"
|
||||
|
|
||||
not package.regexpMatch("[a-zA-Z0-9_\\.]*") and
|
||||
result = "Dubious package \"" + package + "\" in " + pred + " model."
|
||||
@@ -541,7 +510,7 @@ private predicate elementSpec(
|
||||
or
|
||||
summaryModel(package, type, subtypes, name, signature, ext, _, _, _, _)
|
||||
or
|
||||
negativeSummaryModel(package, type, name, signature, _) and ext = "" and subtypes = false
|
||||
neutralModel(package, type, name, signature, _) and ext = "" and subtypes = false
|
||||
}
|
||||
|
||||
private string paramsStringPart(Callable c, int i) {
|
||||
@@ -590,7 +559,7 @@ private Element interpretElement0(
|
||||
)
|
||||
}
|
||||
|
||||
/** Gets the source/sink/summary/negativesummary element corresponding to the supplied parameters. */
|
||||
/** Gets the source/sink/summary/neutral element corresponding to the supplied parameters. */
|
||||
Element interpretElement(
|
||||
string package, string type, boolean subtypes, string name, string signature, string ext
|
||||
) {
|
||||
|
||||
@@ -246,14 +246,14 @@ module Public {
|
||||
predicate isAutoGenerated() { none() }
|
||||
}
|
||||
|
||||
/** A callable with a flow summary stating there is no flow via the callable. */
|
||||
class NegativeSummarizedCallable extends SummarizedCallableBase {
|
||||
NegativeSummarizedCallable() { negativeSummaryElement(this, _) }
|
||||
/** A callable where there is no flow via the callable. */
|
||||
class NeutralCallable extends SummarizedCallableBase {
|
||||
NeutralCallable() { neutralElement(this, _) }
|
||||
|
||||
/**
|
||||
* Holds if the negative summary is auto generated.
|
||||
* Holds if the neutral is auto generated.
|
||||
*/
|
||||
predicate isAutoGenerated() { negativeSummaryElement(this, true) }
|
||||
predicate isAutoGenerated() { neutralElement(this, true) }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1161,9 +1161,9 @@ module Private {
|
||||
string toString() { result = super.toString() }
|
||||
}
|
||||
|
||||
/** A flow summary to include in the `negativeSummary/1` query predicate. */
|
||||
abstract class RelevantNegativeSummarizedCallable instanceof NegativeSummarizedCallable {
|
||||
/** Gets the string representation of this callable used by `summary/1`. */
|
||||
/** A model to include in the `neutral/1` query predicate. */
|
||||
abstract class RelevantNeutralCallable instanceof NeutralCallable {
|
||||
/** Gets the string representation of this callable used by `neutral/1`. */
|
||||
abstract string getCallableCsv();
|
||||
|
||||
string toString() { result = super.toString() }
|
||||
@@ -1180,13 +1180,13 @@ module Private {
|
||||
if c.isAutoGenerated() then result = "generated" else result = "manual"
|
||||
}
|
||||
|
||||
private string renderProvenanceNegative(NegativeSummarizedCallable c) {
|
||||
private string renderProvenanceNeutral(NeutralCallable c) {
|
||||
if c.isAutoGenerated() then result = "generated" else result = "manual"
|
||||
}
|
||||
|
||||
/**
|
||||
* A query predicate for outputting flow summaries in semi-colon separated format in QL tests.
|
||||
* The syntax is: "namespace;type;overrides;name;signature;ext;inputspec;outputspec;kind;provenance"",
|
||||
* The syntax is: "namespace;type;overrides;name;signature;ext;inputspec;outputspec;kind;provenance",
|
||||
* ext is hardcoded to empty.
|
||||
*/
|
||||
query predicate summary(string csv) {
|
||||
@@ -1205,14 +1205,14 @@ module Private {
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if a negative flow summary `csv` exists (semi-colon separated format). Used for testing purposes.
|
||||
* Holds if a neutral model `csv` exists (semi-colon separated format). Used for testing purposes.
|
||||
* The syntax is: "namespace;type;name;signature;provenance"",
|
||||
*/
|
||||
query predicate negativeSummary(string csv) {
|
||||
exists(RelevantNegativeSummarizedCallable c |
|
||||
query predicate neutral(string csv) {
|
||||
exists(RelevantNeutralCallable c |
|
||||
csv =
|
||||
c.getCallableCsv() // Callable information
|
||||
+ renderProvenanceNegative(c) // provenance
|
||||
+ renderProvenanceNeutral(c) // provenance
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,12 +163,12 @@ predicate summaryElement(
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if a negative flow summary exists for `c`, which means that there is no
|
||||
* flow through `c`. The flag `generated` states whether the summary is autogenerated.
|
||||
* Holds if a neutral model exists for `c`, which means that there is no
|
||||
* flow through `c`. The flag `generated` states whether the model is autogenerated.
|
||||
*/
|
||||
predicate negativeSummaryElement(SummarizedCallableBase c, boolean generated) {
|
||||
predicate neutralElement(SummarizedCallableBase c, boolean generated) {
|
||||
exists(string namespace, string type, string name, string signature, string provenance |
|
||||
negativeSummaryModel(namespace, type, name, signature, provenance) and
|
||||
neutralModel(namespace, type, name, signature, provenance) and
|
||||
generated = isGenerated(provenance) and
|
||||
c.asCallable() = interpretElement(namespace, type, false, name, signature, "")
|
||||
)
|
||||
|
||||
@@ -14,7 +14,7 @@ private predicate relevant(ExternalApi api) {
|
||||
not api.isUninteresting() and
|
||||
(
|
||||
api.isSupported() or
|
||||
api = any(FlowSummaryImpl::Public::NegativeSummarizedCallable nsc).asCallable()
|
||||
api = any(FlowSummaryImpl::Public::NeutralCallable nsc).asCallable()
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ import ExternalApi
|
||||
private predicate relevant(ExternalApi api) {
|
||||
not api.isUninteresting() and
|
||||
not api.isSupported() and
|
||||
not api = any(FlowSummaryImpl::Public::NegativeSummarizedCallable nsc).asCallable()
|
||||
not api = any(FlowSummaryImpl::Public::NeutralCallable nsc).asCallable()
|
||||
}
|
||||
|
||||
from string apiName, int usages
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
* @name Capture negative summary models.
|
||||
* @description Finds negative summary models to be used by other queries.
|
||||
* @name Capture neutral models.
|
||||
* @description Finds neutral models to be used by other queries.
|
||||
* @kind diagnostic
|
||||
* @id java/utils/model-generator/negative-summary-models
|
||||
* @id java/utils/model-generator/neutral-models
|
||||
* @tags model-generator
|
||||
*/
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
# Tool to regenerate existing framework CSV models.
|
||||
|
||||
from pathlib import Path
|
||||
import json
|
||||
import os
|
||||
import shutil
|
||||
@@ -37,7 +36,7 @@ def regenerateModel(lgtmSlug, extractedDb):
|
||||
modelFile = lgtmSlugToModelFile[lgtmSlug]
|
||||
codeQlRoot = findGitRoot()
|
||||
subprocess.check_call([codeQlRoot + "/java/ql/src/utils/model-generator/GenerateFlowModel.py",
|
||||
"--with-summaries", "--with-sinks", "--with-negative-summaries",
|
||||
"--with-summaries", "--with-sinks", "--with-neutrals",
|
||||
extractedDb, modelFile])
|
||||
print("Regenerated " + modelFile)
|
||||
shutil.rmtree(tmpDir)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @name Extract MaD negative summary model rows.
|
||||
* @description This extracts the Models as data negative summary model rows.
|
||||
* @id java/utils/modelconverter/generate-data-extensions-negative-summary
|
||||
* @name Extract MaD neutral model rows.
|
||||
* @description This extracts the Models as data neutral model rows.
|
||||
* @id java/utils/modelconverter/generate-data-extensions-neutral
|
||||
*/
|
||||
|
||||
import java
|
||||
@@ -9,6 +9,6 @@ import semmle.code.java.dataflow.ExternalFlow
|
||||
|
||||
from string package, string type, string name, string signature, string provenance
|
||||
where
|
||||
negativeSummaryModel(package, type, name, signature, provenance) and
|
||||
neutralModel(package, type, name, signature, provenance) and
|
||||
provenance != "generated"
|
||||
select package, type, name, signature, provenance order by package, type, name, signature
|
||||
@@ -58,9 +58,7 @@ private string asSummaryModel(TargetApiSpecific api, string input, string output
|
||||
+ "generated"
|
||||
}
|
||||
|
||||
string asNegativeSummaryModel(TargetApiSpecific api) {
|
||||
result = asPartialNegativeModel(api) + "generated"
|
||||
}
|
||||
string asNeutralModel(TargetApiSpecific api) { result = asPartialNeutralModel(api) + "generated" }
|
||||
|
||||
/**
|
||||
* Gets the value summary model for `api` with `input` and `output`.
|
||||
|
||||
@@ -131,9 +131,9 @@ string asPartialModel(TargetApiSpecific api) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes the first 4 columns for negative CSV rows.
|
||||
* Computes the first 4 columns for neutral CSV rows.
|
||||
*/
|
||||
string asPartialNegativeModel(TargetApiSpecific api) {
|
||||
string asPartialNeutralModel(TargetApiSpecific api) {
|
||||
exists(string type, string name, string parameters |
|
||||
partialModel(api, type, name, parameters) and
|
||||
result =
|
||||
|
||||
@@ -77,10 +77,10 @@ string captureFlow(DataFlowTargetApi api) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the negative summary for `api`, if any.
|
||||
* A negative summary is generated, if there does not exist any positive flow.
|
||||
* Gets the neutral summary for `api`, if any.
|
||||
* A neutral model is generated, if there does not exist any summary model.
|
||||
*/
|
||||
string captureNoFlow(DataFlowTargetApi api) {
|
||||
not exists(captureFlow(api)) and
|
||||
result = asNegativeSummaryModel(api)
|
||||
result = asNeutralModel(api)
|
||||
}
|
||||
|
||||
@@ -1,82 +1,21 @@
|
||||
test.kt:
|
||||
# 0| [CompilationUnit] test
|
||||
# 3| 1: [Interface] A
|
||||
# 3| 1: [Constructor] A
|
||||
#-----| 4: (Parameters)
|
||||
# 3| 0: [Parameter] c1
|
||||
# 3| 0: [TypeAccess] Class<?>
|
||||
# 3| 0: [WildcardTypeAccess] ? ...
|
||||
# 3| 1: [Parameter] c2
|
||||
# 3| 0: [TypeAccess] Class<? extends CharSequence>
|
||||
# 3| 0: [WildcardTypeAccess] ? ...
|
||||
# 3| 0: [TypeAccess] CharSequence
|
||||
# 3| 2: [Parameter] c3
|
||||
# 3| 0: [TypeAccess] Class<String>
|
||||
# 3| 0: [TypeAccess] String
|
||||
# 3| 3: [Parameter] c4
|
||||
# 3| 0: [TypeAccess] Class<?>[]
|
||||
# 3| 0: [TypeAccess] Class<?>
|
||||
# 3| 0: [WildcardTypeAccess] ? ...
|
||||
# 3| 5: [BlockStmt] { ... }
|
||||
# 3| 0: [SuperConstructorInvocationStmt] super(...)
|
||||
# 3| 1: [BlockStmt] { ... }
|
||||
# 3| 0: [ExprStmt] <Expr>;
|
||||
# 3| 0: [KtInitializerAssignExpr] ...=...
|
||||
# 3| 0: [VarAccess] c1
|
||||
# 3| 1: [ExprStmt] <Expr>;
|
||||
# 3| 0: [KtInitializerAssignExpr] ...=...
|
||||
# 3| 0: [VarAccess] c2
|
||||
# 3| 2: [ExprStmt] <Expr>;
|
||||
# 3| 0: [KtInitializerAssignExpr] ...=...
|
||||
# 3| 0: [VarAccess] c3
|
||||
# 3| 3: [ExprStmt] <Expr>;
|
||||
# 3| 0: [KtInitializerAssignExpr] ...=...
|
||||
# 3| 0: [VarAccess] c4
|
||||
# 3| 2: [FieldDeclaration] Class<?> c1;
|
||||
# 3| -1: [TypeAccess] Class<?>
|
||||
# 3| 0: [WildcardTypeAccess] ? ...
|
||||
# 3| 0: [VarAccess] c1
|
||||
# 3| 3: [Method] c1
|
||||
#-----| -3: (Annotations)
|
||||
# 0| 1: [Annotation] Retention
|
||||
# 0| 1: [VarAccess] RetentionPolicy.RUNTIME
|
||||
# 0| -1: [TypeAccess] RetentionPolicy
|
||||
# 3| 1: [Method] c1
|
||||
# 3| 3: [TypeAccess] Class<?>
|
||||
# 3| 0: [WildcardTypeAccess] ? ...
|
||||
# 3| 5: [BlockStmt] { ... }
|
||||
# 3| 0: [ReturnStmt] return ...
|
||||
# 3| 0: [VarAccess] this.c1
|
||||
# 3| -1: [ThisAccess] this
|
||||
# 3| 4: [FieldDeclaration] Class<? extends CharSequence> c2;
|
||||
# 3| -1: [TypeAccess] Class<? extends CharSequence>
|
||||
# 3| 0: [WildcardTypeAccess] ? ...
|
||||
# 3| 0: [TypeAccess] CharSequence
|
||||
# 3| 0: [VarAccess] c2
|
||||
# 3| 5: [Method] c2
|
||||
# 3| 2: [Method] c2
|
||||
# 3| 3: [TypeAccess] Class<? extends CharSequence>
|
||||
# 3| 0: [WildcardTypeAccess] ? ...
|
||||
# 3| 0: [TypeAccess] CharSequence
|
||||
# 3| 5: [BlockStmt] { ... }
|
||||
# 3| 0: [ReturnStmt] return ...
|
||||
# 3| 0: [VarAccess] this.c2
|
||||
# 3| -1: [ThisAccess] this
|
||||
# 3| 6: [FieldDeclaration] Class<String> c3;
|
||||
# 3| -1: [TypeAccess] Class<String>
|
||||
# 3| 0: [TypeAccess] String
|
||||
# 3| 0: [VarAccess] c3
|
||||
# 3| 7: [Method] c3
|
||||
# 3| 3: [Method] c3
|
||||
# 3| 3: [TypeAccess] Class<String>
|
||||
# 3| 0: [TypeAccess] String
|
||||
# 3| 5: [BlockStmt] { ... }
|
||||
# 3| 0: [ReturnStmt] return ...
|
||||
# 3| 0: [VarAccess] this.c3
|
||||
# 3| -1: [ThisAccess] this
|
||||
# 3| 8: [FieldDeclaration] Class<?>[] c4;
|
||||
# 3| -1: [TypeAccess] Class<?>[]
|
||||
# 3| 0: [TypeAccess] Class<?>
|
||||
# 3| 0: [WildcardTypeAccess] ? ...
|
||||
# 3| 0: [VarAccess] c4
|
||||
# 3| 9: [Method] c4
|
||||
# 3| 4: [Method] c4
|
||||
# 3| 3: [TypeAccess] Class<?>[]
|
||||
# 3| 0: [TypeAccess] Class<?>
|
||||
# 3| 0: [WildcardTypeAccess] ? ...
|
||||
# 3| 5: [BlockStmt] { ... }
|
||||
# 3| 0: [ReturnStmt] return ...
|
||||
# 3| 0: [VarAccess] this.c4
|
||||
# 3| -1: [ThisAccess] this
|
||||
|
||||
@@ -1,35 +1,9 @@
|
||||
classExprs
|
||||
| test.kt:3:20:3:36 | ...=... | Class<?> |
|
||||
| test.kt:3:20:3:36 | Class<?> | Class<?> |
|
||||
| test.kt:3:20:3:36 | Class<?> | Class<?> |
|
||||
| test.kt:3:20:3:36 | Class<?> | Class<?> |
|
||||
| test.kt:3:20:3:36 | c1 | Class<?> |
|
||||
| test.kt:3:20:3:36 | c1 | Class<?> |
|
||||
| test.kt:3:20:3:36 | this.c1 | Class<?> |
|
||||
| test.kt:3:39:3:70 | ...=... | Class<? extends CharSequence> |
|
||||
| test.kt:3:39:3:70 | Class<? extends CharSequence> | Class<? extends CharSequence> |
|
||||
| test.kt:3:39:3:70 | Class<? extends CharSequence> | Class<? extends CharSequence> |
|
||||
| test.kt:3:39:3:70 | Class<? extends CharSequence> | Class<? extends CharSequence> |
|
||||
| test.kt:3:39:3:70 | c2 | Class<? extends CharSequence> |
|
||||
| test.kt:3:39:3:70 | c2 | Class<? extends CharSequence> |
|
||||
| test.kt:3:39:3:70 | this.c2 | Class<? extends CharSequence> |
|
||||
| test.kt:3:73:3:94 | ...=... | Class<String> |
|
||||
| test.kt:3:73:3:94 | Class<String> | Class<String> |
|
||||
| test.kt:3:73:3:94 | Class<String> | Class<String> |
|
||||
| test.kt:3:73:3:94 | Class<String> | Class<String> |
|
||||
| test.kt:3:73:3:94 | c3 | Class<String> |
|
||||
| test.kt:3:73:3:94 | c3 | Class<String> |
|
||||
| test.kt:3:73:3:94 | this.c3 | Class<String> |
|
||||
| test.kt:3:97:3:120 | ...=... | Class<?>[] |
|
||||
| test.kt:3:97:3:120 | Class<?> | Class<?> |
|
||||
| test.kt:3:97:3:120 | Class<?> | Class<?> |
|
||||
| test.kt:3:97:3:120 | Class<?> | Class<?> |
|
||||
| test.kt:3:97:3:120 | Class<?>[] | Class<?>[] |
|
||||
| test.kt:3:97:3:120 | Class<?>[] | Class<?>[] |
|
||||
| test.kt:3:97:3:120 | Class<?>[] | Class<?>[] |
|
||||
| test.kt:3:97:3:120 | c4 | Class<?>[] |
|
||||
| test.kt:3:97:3:120 | c4 | Class<?>[] |
|
||||
| test.kt:3:97:3:120 | this.c4 | Class<?>[] |
|
||||
#select
|
||||
| test.kt:3:20:3:36 | c1 | Class<?> |
|
||||
| test.kt:3:39:3:70 | c2 | Class<? extends CharSequence> |
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
public @interface Annot0j {
|
||||
int abc() default 0;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
public @interface Annot1j {
|
||||
int a() default 2;
|
||||
|
||||
String b() default "ab";
|
||||
|
||||
Class c() default X.class;
|
||||
|
||||
Y d() default Y.A;
|
||||
|
||||
Y[] e() default { Y.A, Y.B };
|
||||
|
||||
Annot0j f() default @Annot0j(
|
||||
abc = 1
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,280 @@
|
||||
Annot0j.java:
|
||||
# 0| [CompilationUnit] Annot0j
|
||||
# 1| 1: [Interface] Annot0j
|
||||
# 2| 1: [Method] abc
|
||||
# 2| 3: [TypeAccess] int
|
||||
Annot1j.java:
|
||||
# 0| [CompilationUnit] Annot1j
|
||||
# 1| 1: [Interface] Annot1j
|
||||
# 2| 1: [Method] a
|
||||
# 2| 3: [TypeAccess] int
|
||||
# 4| 2: [Method] b
|
||||
# 4| 3: [TypeAccess] String
|
||||
# 6| 3: [Method] c
|
||||
# 6| 3: [TypeAccess] Class<>
|
||||
# 8| 4: [Method] d
|
||||
# 8| 3: [TypeAccess] Y
|
||||
# 10| 5: [Method] e
|
||||
# 10| 3: [ArrayTypeAccess] ...[]
|
||||
# 10| 0: [TypeAccess] Y
|
||||
# 12| 6: [Method] f
|
||||
# 12| 3: [TypeAccess] Annot0j
|
||||
def.kt:
|
||||
# 0| [CompilationUnit] def
|
||||
# 0| 1: [Class] DefKt
|
||||
# 46| 2: [Method] fn
|
||||
#-----| 1: (Annotations)
|
||||
# 45| 1: [Annotation] Annot0k
|
||||
# 0| 1: [IntegerLiteral] 0
|
||||
#-----| 2: (Generic Parameters)
|
||||
# 46| 0: [TypeVariable] T
|
||||
# 46| 3: [TypeAccess] Unit
|
||||
#-----| 4: (Parameters)
|
||||
# 46| 0: [Parameter] a
|
||||
#-----| -1: (Annotations)
|
||||
# 46| 1: [Annotation] Annot0k
|
||||
# 0| 1: [IntegerLiteral] 0
|
||||
# 46| 0: [TypeAccess] Annot0k
|
||||
# 46| 5: [BlockStmt] { ... }
|
||||
# 47| 0: [ExprStmt] <Expr>;
|
||||
# 47| 0: [MethodAccess] println(...)
|
||||
# 47| -1: [TypeAccess] ConsoleKt
|
||||
# 47| 0: [MethodAccess] a(...)
|
||||
# 47| -1: [VarAccess] a
|
||||
# 50| 1: [LocalVariableDeclStmt] var ...;
|
||||
# 50| 1: [LocalVariableDeclExpr] x
|
||||
# 50| 0: [IntegerLiteral] 10
|
||||
# 53| 3: [FieldDeclaration] int p;
|
||||
#-----| -2: (Annotations)
|
||||
# 56| 1: [Annotation] Annot0k
|
||||
# 0| 1: [IntegerLiteral] 0
|
||||
# 53| -1: [TypeAccess] int
|
||||
# 57| 0: [IntegerLiteral] 5
|
||||
# 57| 4: [Method] getP
|
||||
#-----| 1: (Annotations)
|
||||
# 54| 1: [Annotation] Annot0k
|
||||
# 0| 1: [IntegerLiteral] 0
|
||||
# 57| 3: [TypeAccess] int
|
||||
# 57| 5: [BlockStmt] { ... }
|
||||
# 57| 0: [ReturnStmt] return ...
|
||||
# 57| 0: [VarAccess] DefKt.p
|
||||
# 57| -1: [TypeAccess] DefKt
|
||||
# 57| 5: [Method] setP
|
||||
#-----| 1: (Annotations)
|
||||
# 55| 1: [Annotation] Annot0k
|
||||
# 0| 1: [IntegerLiteral] 0
|
||||
# 57| 3: [TypeAccess] Unit
|
||||
#-----| 4: (Parameters)
|
||||
# 57| 0: [Parameter] <set-?>
|
||||
# 57| 0: [TypeAccess] int
|
||||
# 57| 5: [BlockStmt] { ... }
|
||||
# 57| 0: [ExprStmt] <Expr>;
|
||||
# 57| 0: [AssignExpr] ...=...
|
||||
# 57| 0: [VarAccess] DefKt.p
|
||||
# 57| -1: [TypeAccess] DefKt
|
||||
# 57| 1: [VarAccess] <set-?>
|
||||
# 59| 6: [ExtensionMethod] myExtension
|
||||
# 59| 3: [TypeAccess] Unit
|
||||
#-----| 4: (Parameters)
|
||||
# 59| 0: [Parameter] <this>
|
||||
#-----| -1: (Annotations)
|
||||
# 59| 1: [Annotation] Annot0k
|
||||
# 0| 1: [IntegerLiteral] 0
|
||||
# 59| 0: [TypeAccess] String
|
||||
# 59| 5: [BlockStmt] { ... }
|
||||
# 5| 2: [Interface] Annot0k
|
||||
#-----| -3: (Annotations)
|
||||
# 0| 1: [Annotation] Retention
|
||||
# 0| 1: [VarAccess] RetentionPolicy.RUNTIME
|
||||
# 0| -1: [TypeAccess] RetentionPolicy
|
||||
# 0| 2: [Annotation] Target
|
||||
# 0| 1: [ArrayInit] {...}
|
||||
# 0| 1: [VarAccess] ElementType.TYPE
|
||||
# 0| -1: [TypeAccess] ElementType
|
||||
# 0| 2: [VarAccess] ElementType.FIELD
|
||||
# 0| -1: [TypeAccess] ElementType
|
||||
# 0| 3: [VarAccess] ElementType.METHOD
|
||||
# 0| -1: [TypeAccess] ElementType
|
||||
# 0| 4: [VarAccess] ElementType.PARAMETER
|
||||
# 0| -1: [TypeAccess] ElementType
|
||||
# 0| 5: [VarAccess] ElementType.CONSTRUCTOR
|
||||
# 0| -1: [TypeAccess] ElementType
|
||||
# 0| 6: [VarAccess] ElementType.LOCAL_VARIABLE
|
||||
# 0| -1: [TypeAccess] ElementType
|
||||
# 0| 7: [VarAccess] ElementType.ANNOTATION_TYPE
|
||||
# 0| -1: [TypeAccess] ElementType
|
||||
# 0| 8: [VarAccess] ElementType.TYPE_PARAMETER
|
||||
# 0| -1: [TypeAccess] ElementType
|
||||
# 0| 9: [VarAccess] ElementType.TYPE_USE
|
||||
# 0| -1: [TypeAccess] ElementType
|
||||
# 5| 3: [Annotation] Target
|
||||
# 0| 1: [ArrayInit] {...}
|
||||
# 0| 1: [VarAccess] AnnotationTarget.CLASS
|
||||
# 0| -1: [TypeAccess] AnnotationTarget
|
||||
# 0| 2: [VarAccess] AnnotationTarget.ANNOTATION_CLASS
|
||||
# 0| -1: [TypeAccess] AnnotationTarget
|
||||
# 0| 3: [VarAccess] AnnotationTarget.TYPE_PARAMETER
|
||||
# 0| -1: [TypeAccess] AnnotationTarget
|
||||
# 0| 4: [VarAccess] AnnotationTarget.PROPERTY
|
||||
# 0| -1: [TypeAccess] AnnotationTarget
|
||||
# 0| 5: [VarAccess] AnnotationTarget.FIELD
|
||||
# 0| -1: [TypeAccess] AnnotationTarget
|
||||
# 0| 6: [VarAccess] AnnotationTarget.LOCAL_VARIABLE
|
||||
# 0| -1: [TypeAccess] AnnotationTarget
|
||||
# 0| 7: [VarAccess] AnnotationTarget.VALUE_PARAMETER
|
||||
# 0| -1: [TypeAccess] AnnotationTarget
|
||||
# 0| 8: [VarAccess] AnnotationTarget.CONSTRUCTOR
|
||||
# 0| -1: [TypeAccess] AnnotationTarget
|
||||
# 0| 9: [VarAccess] AnnotationTarget.FUNCTION
|
||||
# 0| -1: [TypeAccess] AnnotationTarget
|
||||
# 0| 10: [VarAccess] AnnotationTarget.PROPERTY_GETTER
|
||||
# 0| -1: [TypeAccess] AnnotationTarget
|
||||
# 0| 11: [VarAccess] AnnotationTarget.PROPERTY_SETTER
|
||||
# 0| -1: [TypeAccess] AnnotationTarget
|
||||
# 0| 12: [VarAccess] AnnotationTarget.TYPE
|
||||
# 0| -1: [TypeAccess] AnnotationTarget
|
||||
# 0| 13: [VarAccess] AnnotationTarget.FILE
|
||||
# 0| -1: [TypeAccess] AnnotationTarget
|
||||
# 0| 14: [VarAccess] AnnotationTarget.TYPEALIAS
|
||||
# 0| -1: [TypeAccess] AnnotationTarget
|
||||
# 21| 1: [Method] a
|
||||
#-----| 1: (Annotations)
|
||||
# 21| 1: [Annotation] JvmName
|
||||
# 0| 1: [StringLiteral] "a"
|
||||
# 21| 3: [TypeAccess] int
|
||||
# 23| 3: [Interface] Annot1k
|
||||
#-----| -3: (Annotations)
|
||||
# 0| 1: [Annotation] Retention
|
||||
# 0| 1: [VarAccess] RetentionPolicy.RUNTIME
|
||||
# 0| -1: [TypeAccess] RetentionPolicy
|
||||
# 23| 2: [Annotation] Annot0k
|
||||
# 0| 1: [IntegerLiteral] 0
|
||||
# 25| 1: [Method] a
|
||||
# 25| 3: [TypeAccess] int
|
||||
# 26| 2: [Method] b
|
||||
# 26| 3: [TypeAccess] String
|
||||
# 27| 3: [Method] c
|
||||
# 27| 3: [TypeAccess] Class<?>
|
||||
# 27| 0: [WildcardTypeAccess] ? ...
|
||||
# 28| 4: [Method] d
|
||||
# 28| 3: [TypeAccess] Y
|
||||
# 29| 5: [Method] e
|
||||
# 29| 3: [TypeAccess] Y[]
|
||||
# 29| 0: [TypeAccess] Y
|
||||
# 30| 6: [Method] f
|
||||
# 30| 3: [TypeAccess] Annot0k
|
||||
# 33| 4: [Class] X
|
||||
# 33| 1: [Constructor] X
|
||||
# 33| 5: [BlockStmt] { ... }
|
||||
# 33| 0: [SuperConstructorInvocationStmt] super(...)
|
||||
# 33| 1: [BlockStmt] { ... }
|
||||
# 34| 5: [Class] Y
|
||||
# 0| 2: [Method] valueOf
|
||||
# 0| 3: [TypeAccess] Y
|
||||
#-----| 4: (Parameters)
|
||||
# 0| 0: [Parameter] value
|
||||
# 0| 0: [TypeAccess] String
|
||||
# 0| 3: [Method] values
|
||||
# 0| 3: [TypeAccess] Y[]
|
||||
# 0| 0: [TypeAccess] Y
|
||||
# 34| 4: [Constructor] Y
|
||||
# 34| 5: [BlockStmt] { ... }
|
||||
# 34| 0: [ExprStmt] <Expr>;
|
||||
# 34| 0: [ClassInstanceExpr] new Enum(...)
|
||||
# 34| -3: [TypeAccess] Enum<Y>
|
||||
# 34| 0: [TypeAccess] Y
|
||||
# 34| 0: [NullLiteral] null
|
||||
# 34| 1: [IntegerLiteral] 0
|
||||
# 34| 1: [BlockStmt] { ... }
|
||||
# 35| 5: [FieldDeclaration] Y A;
|
||||
# 35| -1: [TypeAccess] Y
|
||||
# 35| 0: [ClassInstanceExpr] new Y(...)
|
||||
# 35| -3: [TypeAccess] Y
|
||||
# 35| 6: [FieldDeclaration] Y B;
|
||||
# 35| -1: [TypeAccess] Y
|
||||
# 35| 0: [ClassInstanceExpr] new Y(...)
|
||||
# 35| -3: [TypeAccess] Y
|
||||
# 35| 7: [FieldDeclaration] Y C;
|
||||
# 35| -1: [TypeAccess] Y
|
||||
# 35| 0: [ClassInstanceExpr] new Y(...)
|
||||
# 35| -3: [TypeAccess] Y
|
||||
# 38| 6: [Class] Z
|
||||
#-----| -3: (Annotations)
|
||||
# 38| 1: [Annotation] Annot0k
|
||||
# 0| 1: [IntegerLiteral] 1
|
||||
# 39| 2: [Annotation] Annot1k
|
||||
# 0| 1: [IntegerLiteral] 2
|
||||
# 0| 2: [StringLiteral] "ab"
|
||||
# 0| 3: [TypeLiteral] X.class
|
||||
# 0| 0: [TypeAccess] X
|
||||
# 0| 4: [VarAccess] Y.B
|
||||
# 0| -1: [TypeAccess] Y
|
||||
# 0| 5: [ArrayInit] {...}
|
||||
# 0| 1: [VarAccess] Y.C
|
||||
# 0| -1: [TypeAccess] Y
|
||||
# 0| 2: [VarAccess] Y.A
|
||||
# 0| -1: [TypeAccess] Y
|
||||
# 0| 6: [Annotation] Annot0k
|
||||
# 0| 1: [IntegerLiteral] 1
|
||||
# 42| 1: [Constructor] Z
|
||||
#-----| 1: (Annotations)
|
||||
# 41| 1: [Annotation] Annot0k
|
||||
# 0| 1: [IntegerLiteral] 0
|
||||
# 41| 5: [BlockStmt] { ... }
|
||||
# 42| 0: [SuperConstructorInvocationStmt] super(...)
|
||||
# 42| 1: [BlockStmt] { ... }
|
||||
use.java:
|
||||
# 0| [CompilationUnit] use
|
||||
# 1| 1: [Class] use
|
||||
#-----| -1: (Base Types)
|
||||
# 1| 0: [TypeAccess] Annot0k
|
||||
# 3| 2: [Method] a
|
||||
#-----| 1: (Annotations)
|
||||
# 2| 1: [Annotation] Override
|
||||
# 3| 3: [TypeAccess] int
|
||||
# 3| 5: [BlockStmt] { ... }
|
||||
# 3| 0: [ReturnStmt] return ...
|
||||
# 3| 0: [IntegerLiteral] 1
|
||||
# 6| 3: [Method] annotationType
|
||||
#-----| 1: (Annotations)
|
||||
# 5| 1: [Annotation] Override
|
||||
# 6| 3: [TypeAccess] Class<? extends Annotation>
|
||||
# 6| 0: [WildcardTypeAccess] ? ...
|
||||
# 6| 0: [TypeAccess] Annotation
|
||||
# 6| 5: [BlockStmt] { ... }
|
||||
# 7| 0: [ReturnStmt] return ...
|
||||
# 7| 0: [NullLiteral] null
|
||||
# 14| 4: [Class] Z
|
||||
#-----| -3: (Annotations)
|
||||
# 10| 1: [Annotation] Annot0j
|
||||
# 10| 1: [IntegerLiteral] 1
|
||||
# 11| 2: [Annotation] Annot1j
|
||||
# 11| 1: [IntegerLiteral] 1
|
||||
# 11| 2: [StringLiteral] "ac"
|
||||
# 11| 3: [TypeLiteral] X.class
|
||||
# 11| 0: [TypeAccess] X
|
||||
# 11| 4: [VarAccess] Y.B
|
||||
# 11| -1: [TypeAccess] Y
|
||||
# 11| 5: [ArrayInit] {...}
|
||||
# 11| 3: [VarAccess] Y.C
|
||||
# 11| -1: [TypeAccess] Y
|
||||
# 11| 4: [VarAccess] Y.A
|
||||
# 11| -1: [TypeAccess] Y
|
||||
# 11| 6: [Annotation] Annot0j
|
||||
# 11| 1: [IntegerLiteral] 2
|
||||
# 12| 3: [Annotation] Annot0k
|
||||
# 12| 1: [IntegerLiteral] 1
|
||||
# 13| 4: [Annotation] Annot1k
|
||||
# 13| 1: [IntegerLiteral] 1
|
||||
# 13| 2: [StringLiteral] "ac"
|
||||
# 13| 3: [TypeLiteral] X.class
|
||||
# 13| 0: [TypeAccess] X
|
||||
# 13| 4: [VarAccess] Y.B
|
||||
# 13| -1: [TypeAccess] Y
|
||||
# 13| 5: [ArrayInit] {...}
|
||||
# 13| 3: [VarAccess] Y.C
|
||||
# 13| -1: [TypeAccess] Y
|
||||
# 13| 4: [VarAccess] Y.A
|
||||
# 13| -1: [TypeAccess] Y
|
||||
# 13| 6: [Annotation] Annot0k
|
||||
# 13| 1: [IntegerLiteral] 2
|
||||
@@ -0,0 +1 @@
|
||||
semmle/code/java/PrintAst.ql
|
||||
@@ -1,2 +1,82 @@
|
||||
| def.kt:2:1:2:31 | SomeAnnotation | Interface |
|
||||
| use.java:2:23:2:25 | use | Class |
|
||||
annotationDeclarations
|
||||
| Annot0j.java:1:19:1:25 | Annot0j | Annot0j.java:2:9:2:11 | abc |
|
||||
| Annot1j.java:1:19:1:25 | Annot1j | Annot1j.java:2:9:2:9 | a |
|
||||
| Annot1j.java:1:19:1:25 | Annot1j | Annot1j.java:4:12:4:12 | b |
|
||||
| Annot1j.java:1:19:1:25 | Annot1j | Annot1j.java:6:11:6:11 | c |
|
||||
| Annot1j.java:1:19:1:25 | Annot1j | Annot1j.java:8:7:8:7 | d |
|
||||
| Annot1j.java:1:19:1:25 | Annot1j | Annot1j.java:10:9:10:9 | e |
|
||||
| Annot1j.java:1:19:1:25 | Annot1j | Annot1j.java:12:13:12:13 | f |
|
||||
| def.kt:5:1:21:60 | Annot0k | def.kt:21:44:21:59 | a |
|
||||
| def.kt:23:1:31:1 | Annot1k | def.kt:25:5:25:18 | a |
|
||||
| def.kt:23:1:31:1 | Annot1k | def.kt:26:5:26:24 | b |
|
||||
| def.kt:23:1:31:1 | Annot1k | def.kt:27:5:27:31 | c |
|
||||
| def.kt:23:1:31:1 | Annot1k | def.kt:28:5:28:18 | d |
|
||||
| def.kt:23:1:31:1 | Annot1k | def.kt:29:5:29:32 | e |
|
||||
| def.kt:23:1:31:1 | Annot1k | def.kt:30:5:30:31 | f |
|
||||
annotations
|
||||
| def.kt:0:0:0:0 | Annot0k | def.kt:39:1:39:40 | Annot1k | def.kt:5:1:21:60 | Annot0k |
|
||||
| def.kt:23:1:23:8 | Annot0k | def.kt:23:1:31:1 | Annot1k | def.kt:5:1:21:60 | Annot0k |
|
||||
| def.kt:38:1:38:17 | Annot0k | def.kt:38:1:43:1 | Z | def.kt:5:1:21:60 | Annot0k |
|
||||
| def.kt:39:1:39:40 | Annot1k | def.kt:38:1:43:1 | Z | def.kt:23:1:31:1 | Annot1k |
|
||||
| def.kt:41:5:41:12 | Annot0k | def.kt:42:5:42:19 | Z | def.kt:5:1:21:60 | Annot0k |
|
||||
| def.kt:45:1:45:8 | Annot0k | def.kt:46:1:51:1 | fn | def.kt:5:1:21:60 | Annot0k |
|
||||
| def.kt:46:21:46:28 | Annot0k | def.kt:46:21:46:39 | a | def.kt:5:1:21:60 | Annot0k |
|
||||
| def.kt:54:1:54:12 | Annot0k | def.kt:57:1:57:23 | getP | def.kt:5:1:21:60 | Annot0k |
|
||||
| def.kt:55:1:55:12 | Annot0k | def.kt:57:1:57:23 | setP | def.kt:5:1:21:60 | Annot0k |
|
||||
| def.kt:56:1:56:14 | Annot0k | def.kt:53:1:57:23 | p | def.kt:5:1:21:60 | Annot0k |
|
||||
| def.kt:59:5:59:21 | Annot0k | def.kt:59:5:59:28 | <this> | def.kt:5:1:21:60 | Annot0k |
|
||||
| use.java:10:5:10:21 | Annot0j | use.java:14:18:14:18 | Z | Annot0j.java:1:19:1:25 | Annot0j |
|
||||
| use.java:11:5:11:90 | Annot1j | use.java:14:18:14:18 | Z | Annot1j.java:1:19:1:25 | Annot1j |
|
||||
| use.java:11:73:11:89 | Annot0j | use.java:11:5:11:90 | Annot1j | Annot0j.java:1:19:1:25 | Annot0j |
|
||||
| use.java:12:5:12:19 | Annot0k | use.java:14:18:14:18 | Z | def.kt:5:1:21:60 | Annot0k |
|
||||
| use.java:13:5:13:88 | Annot1k | use.java:14:18:14:18 | Z | def.kt:23:1:31:1 | Annot1k |
|
||||
| use.java:13:73:13:87 | Annot0k | use.java:13:5:13:88 | Annot1k | def.kt:5:1:21:60 | Annot0k |
|
||||
annotationValues
|
||||
| def.kt:0:0:0:0 | Annot0k | def.kt:0:0:0:0 | 1 |
|
||||
| def.kt:0:0:0:0 | Retention | def.kt:0:0:0:0 | RetentionPolicy.RUNTIME |
|
||||
| def.kt:0:0:0:0 | Retention | def.kt:0:0:0:0 | RetentionPolicy.RUNTIME |
|
||||
| def.kt:0:0:0:0 | Target | def.kt:0:0:0:0 | {...} |
|
||||
| def.kt:5:1:20:1 | Target | def.kt:0:0:0:0 | {...} |
|
||||
| def.kt:21:26:21:42 | JvmName | def.kt:0:0:0:0 | "a" |
|
||||
| def.kt:23:1:23:8 | Annot0k | def.kt:0:0:0:0 | 0 |
|
||||
| def.kt:38:1:38:17 | Annot0k | def.kt:0:0:0:0 | 1 |
|
||||
| def.kt:39:1:39:40 | Annot1k | def.kt:0:0:0:0 | 2 |
|
||||
| def.kt:39:1:39:40 | Annot1k | def.kt:0:0:0:0 | "ab" |
|
||||
| def.kt:39:1:39:40 | Annot1k | def.kt:0:0:0:0 | Annot0k |
|
||||
| def.kt:39:1:39:40 | Annot1k | def.kt:0:0:0:0 | X.class |
|
||||
| def.kt:39:1:39:40 | Annot1k | def.kt:0:0:0:0 | Y.B |
|
||||
| def.kt:39:1:39:40 | Annot1k | def.kt:0:0:0:0 | {...} |
|
||||
| def.kt:41:5:41:12 | Annot0k | def.kt:0:0:0:0 | 0 |
|
||||
| def.kt:45:1:45:8 | Annot0k | def.kt:0:0:0:0 | 0 |
|
||||
| def.kt:46:21:46:28 | Annot0k | def.kt:0:0:0:0 | 0 |
|
||||
| def.kt:54:1:54:12 | Annot0k | def.kt:0:0:0:0 | 0 |
|
||||
| def.kt:55:1:55:12 | Annot0k | def.kt:0:0:0:0 | 0 |
|
||||
| def.kt:56:1:56:14 | Annot0k | def.kt:0:0:0:0 | 0 |
|
||||
| def.kt:59:5:59:21 | Annot0k | def.kt:0:0:0:0 | 0 |
|
||||
| use.java:10:5:10:21 | Annot0j | use.java:10:20:10:20 | 1 |
|
||||
| use.java:11:5:11:90 | Annot1j | use.java:11:18:11:18 | 1 |
|
||||
| use.java:11:5:11:90 | Annot1j | use.java:11:25:11:28 | "ac" |
|
||||
| use.java:11:5:11:90 | Annot1j | use.java:11:35:11:41 | X.class |
|
||||
| use.java:11:5:11:90 | Annot1j | use.java:11:48:11:50 | Y.B |
|
||||
| use.java:11:5:11:90 | Annot1j | use.java:11:57:11:66 | {...} |
|
||||
| use.java:11:5:11:90 | Annot1j | use.java:11:73:11:89 | Annot0j |
|
||||
| use.java:11:73:11:89 | Annot0j | use.java:11:88:11:88 | 2 |
|
||||
| use.java:12:5:12:19 | Annot0k | use.java:12:18:12:18 | 1 |
|
||||
| use.java:13:5:13:88 | Annot1k | use.java:13:18:13:18 | 1 |
|
||||
| use.java:13:5:13:88 | Annot1k | use.java:13:25:13:28 | "ac" |
|
||||
| use.java:13:5:13:88 | Annot1k | use.java:13:35:13:41 | X.class |
|
||||
| use.java:13:5:13:88 | Annot1k | use.java:13:48:13:50 | Y.B |
|
||||
| use.java:13:5:13:88 | Annot1k | use.java:13:57:13:66 | {...} |
|
||||
| use.java:13:5:13:88 | Annot1k | use.java:13:73:13:87 | Annot0k |
|
||||
| use.java:13:73:13:87 | Annot0k | use.java:13:86:13:86 | 2 |
|
||||
#select
|
||||
| Annot0j.java:1:19:1:25 | Annot0j | Interface |
|
||||
| Annot1j.java:1:19:1:25 | Annot1j | Interface |
|
||||
| def.kt:0:0:0:0 | DefKt | Class |
|
||||
| def.kt:5:1:21:60 | Annot0k | Interface |
|
||||
| def.kt:23:1:31:1 | Annot1k | Interface |
|
||||
| def.kt:33:1:33:10 | X | Class |
|
||||
| def.kt:34:1:36:1 | Y | Class |
|
||||
| def.kt:38:1:43:1 | Z | Class |
|
||||
| use.java:1:14:1:16 | use | Class |
|
||||
| use.java:14:18:14:18 | Z | Class |
|
||||
|
||||
@@ -3,3 +3,18 @@ import java
|
||||
from ClassOrInterface x
|
||||
where x.fromSource()
|
||||
select x, x.getPrimaryQlClasses()
|
||||
|
||||
query predicate annotationDeclarations(AnnotationType at, AnnotationElement ae) {
|
||||
at.fromSource() and
|
||||
at.getAnAnnotationElement() = ae
|
||||
}
|
||||
|
||||
query predicate annotations(Annotation a, Element e, AnnotationType at) {
|
||||
at.fromSource() and
|
||||
a.getAnnotatedElement() = e and
|
||||
at = a.getType()
|
||||
}
|
||||
|
||||
query predicate annotationValues(Annotation a, Expr v) {
|
||||
a.getValue(_) = v and v.getFile().isSourceFile()
|
||||
}
|
||||
|
||||
@@ -1,3 +1,62 @@
|
||||
@file:Annot0k
|
||||
|
||||
annotation class SomeAnnotation
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
@Target(AnnotationTarget.CLASS,
|
||||
AnnotationTarget.ANNOTATION_CLASS,
|
||||
AnnotationTarget.TYPE_PARAMETER,
|
||||
AnnotationTarget.PROPERTY,
|
||||
AnnotationTarget.FIELD,
|
||||
AnnotationTarget.LOCAL_VARIABLE, // TODO
|
||||
AnnotationTarget.VALUE_PARAMETER,
|
||||
AnnotationTarget.CONSTRUCTOR,
|
||||
AnnotationTarget.FUNCTION,
|
||||
AnnotationTarget.PROPERTY_GETTER,
|
||||
AnnotationTarget.PROPERTY_SETTER,
|
||||
AnnotationTarget.TYPE, // TODO
|
||||
//AnnotationTarget.EXPRESSION, // TODO
|
||||
AnnotationTarget.FILE, // TODO
|
||||
AnnotationTarget.TYPEALIAS // TODO
|
||||
)
|
||||
annotation class Annot0k(@get:JvmName("a") val abc: Int = 0)
|
||||
|
||||
@Annot0k
|
||||
annotation class Annot1k(
|
||||
val a: Int = 2,
|
||||
val b: String = "ab",
|
||||
val c: KClass<*> = X::class,
|
||||
val d: Y = Y.A,
|
||||
val e: Array<Y> = [Y.A, Y.B],
|
||||
val f: Annot0k = Annot0k(1)
|
||||
)
|
||||
|
||||
class X {}
|
||||
enum class Y {
|
||||
A,B,C
|
||||
}
|
||||
|
||||
@Annot0k(abc = 1)
|
||||
@Annot1k(d = Y.B, e = arrayOf(Y.C, Y.A))
|
||||
class Z {
|
||||
@Annot0k
|
||||
constructor(){}
|
||||
}
|
||||
|
||||
@Annot0k
|
||||
fun <@Annot0k T> fn(@Annot0k a: Annot0k) {
|
||||
println(a.abc)
|
||||
|
||||
@Annot0k
|
||||
var x = 10
|
||||
}
|
||||
|
||||
@Annot0k
|
||||
@get:Annot0k
|
||||
@set:Annot0k
|
||||
@field:Annot0k
|
||||
var p: @Annot0k Int = 5
|
||||
|
||||
fun @receiver:Annot0k String.myExtension() { }
|
||||
|
||||
@Annot0k
|
||||
typealias AAA = Z
|
||||
|
||||
@@ -1,3 +1,15 @@
|
||||
public class use implements Annot0k {
|
||||
@Override
|
||||
public int a() { return 1; }
|
||||
|
||||
public abstract class use implements SomeAnnotation {}
|
||||
@Override
|
||||
public Class<? extends java.lang.annotation.Annotation> annotationType() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Annot0j(abc = 1)
|
||||
@Annot1j(a = 1, b = "ac", c = X.class, d = Y.B, e = {Y.C, Y.A}, f = @Annot0j(abc = 2))
|
||||
@Annot0k(a = 1)
|
||||
@Annot1k(a = 1, b = "ac", c = X.class, d = Y.B, e = {Y.C, Y.A}, f = @Annot0k(a = 2))
|
||||
public class Z { }
|
||||
}
|
||||
|
||||
@@ -1,84 +1,12 @@
|
||||
test.kt:
|
||||
# 0| [CompilationUnit] test
|
||||
# 1| 1: [Interface] Ann
|
||||
# 1| 1: [Constructor] Ann
|
||||
#-----| 4: (Parameters)
|
||||
# 1| 0: [Parameter] arr1
|
||||
# 1| 0: [TypeAccess] String[]
|
||||
# 1| 0: [TypeAccess] String
|
||||
# 1| 1: [Parameter] arr2
|
||||
# 1| 0: [TypeAccess] int[]
|
||||
# 1| 5: [BlockStmt] { ... }
|
||||
# 1| 0: [SuperConstructorInvocationStmt] super(...)
|
||||
# 1| 1: [BlockStmt] { ... }
|
||||
# 1| 0: [ExprStmt] <Expr>;
|
||||
# 1| 0: [KtInitializerAssignExpr] ...=...
|
||||
# 1| 0: [VarAccess] arr1
|
||||
# 1| 1: [ExprStmt] <Expr>;
|
||||
# 1| 0: [KtInitializerAssignExpr] ...=...
|
||||
# 1| 0: [VarAccess] arr2
|
||||
# 1| 2: [Constructor] Ann
|
||||
#-----| 4: (Parameters)
|
||||
# 1| 0: [Parameter] p0
|
||||
# 1| 0: [TypeAccess] String[]
|
||||
# 1| 1: [Parameter] p1
|
||||
# 1| 0: [TypeAccess] int[]
|
||||
# 1| 2: [Parameter] p2
|
||||
# 1| 0: [TypeAccess] int
|
||||
# 1| 3: [Parameter] p3
|
||||
# 1| 0: [TypeAccess] DefaultConstructorMarker
|
||||
# 1| 5: [BlockStmt] { ... }
|
||||
# 1| 0: [IfStmt] if (...)
|
||||
# 1| 0: [EQExpr] ... == ...
|
||||
# 1| 0: [AndBitwiseExpr] ... & ...
|
||||
# 1| 0: [IntegerLiteral] 1
|
||||
# 1| 1: [VarAccess] p2
|
||||
# 1| 1: [IntegerLiteral] 0
|
||||
# 1| 1: [ExprStmt] <Expr>;
|
||||
# 1| 0: [AssignExpr] ...=...
|
||||
# 1| 0: [VarAccess] p0
|
||||
# 0| 1: [ArrayCreationExpr] new String[]
|
||||
# 0| -2: [ArrayInit] {...}
|
||||
# 0| 0: [StringLiteral] "hello"
|
||||
# 0| 1: [StringLiteral] "world"
|
||||
# 0| -1: [TypeAccess] String
|
||||
# 0| 0: [IntegerLiteral] 2
|
||||
# 1| 1: [IfStmt] if (...)
|
||||
# 1| 0: [EQExpr] ... == ...
|
||||
# 1| 0: [AndBitwiseExpr] ... & ...
|
||||
# 1| 0: [IntegerLiteral] 2
|
||||
# 1| 1: [VarAccess] p2
|
||||
# 1| 1: [IntegerLiteral] 0
|
||||
# 1| 1: [ExprStmt] <Expr>;
|
||||
# 1| 0: [AssignExpr] ...=...
|
||||
# 1| 0: [VarAccess] p1
|
||||
# 0| 1: [ArrayCreationExpr] new int[]
|
||||
# 0| -2: [ArrayInit] {...}
|
||||
# 0| 0: [IntegerLiteral] 1
|
||||
# 0| 1: [IntegerLiteral] 2
|
||||
# 0| 2: [IntegerLiteral] 3
|
||||
# 0| -1: [TypeAccess] int
|
||||
# 0| 0: [IntegerLiteral] 3
|
||||
# 1| 2: [ThisConstructorInvocationStmt] this(...)
|
||||
# 1| 0: [VarAccess] p0
|
||||
# 1| 1: [VarAccess] p1
|
||||
# 1| 3: [FieldDeclaration] String[] arr1;
|
||||
# 1| -1: [TypeAccess] String[]
|
||||
# 1| 0: [TypeAccess] String
|
||||
# 1| 0: [VarAccess] arr1
|
||||
# 1| 4: [Method] arr1
|
||||
#-----| -3: (Annotations)
|
||||
# 0| 1: [Annotation] Retention
|
||||
# 0| 1: [VarAccess] RetentionPolicy.RUNTIME
|
||||
# 0| -1: [TypeAccess] RetentionPolicy
|
||||
# 1| 1: [Method] arr1
|
||||
# 1| 3: [TypeAccess] String[]
|
||||
# 1| 0: [TypeAccess] String
|
||||
# 1| 5: [BlockStmt] { ... }
|
||||
# 1| 0: [ReturnStmt] return ...
|
||||
# 1| 0: [VarAccess] this.arr1
|
||||
# 1| -1: [ThisAccess] this
|
||||
# 1| 5: [Method] arr2
|
||||
# 1| 2: [Method] arr2
|
||||
# 1| 3: [TypeAccess] int[]
|
||||
# 1| 5: [BlockStmt] { ... }
|
||||
# 1| 0: [ReturnStmt] return ...
|
||||
# 1| 0: [VarAccess] this.arr2
|
||||
# 1| -1: [ThisAccess] this
|
||||
# 1| 6: [FieldDeclaration] int[] arr2;
|
||||
# 1| -1: [TypeAccess] int[]
|
||||
# 1| 0: [VarAccess] arr2
|
||||
|
||||
@@ -1,2 +1 @@
|
||||
| exprs.kt:278:52:278:66 | <error expr> | ErrorExpr | unexpected dead end |
|
||||
| exprs.kt:278:52:278:66 | { ... } | BlockStmt | unexpected dead end |
|
||||
|
||||
@@ -35,4 +35,5 @@ MaybeElement enclosingCallable(Expr e) {
|
||||
}
|
||||
|
||||
from Expr e
|
||||
where e.getFile().isSourceFile()
|
||||
select e, enclosingCallable(e), e.getPrimaryQlClasses()
|
||||
|
||||
@@ -9,4 +9,3 @@ class B<T> {
|
||||
val b1 = B<Any>()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,4 +3,3 @@ public class Test() {
|
||||
internal constructor(x: Int, y: Int) : this() { }
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -10,4 +10,3 @@ public class Test {
|
||||
internal fun internalFun() = 3
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -55,6 +55,8 @@ test.kt:
|
||||
# 1| 6: [IntegerLiteral] 23
|
||||
# 1| 7: [NullLiteral] null
|
||||
# 45| 4: [ExtensionMethod] testExtensionFunction
|
||||
#-----| 1: (Annotations)
|
||||
# 44| 1: [Annotation] JvmOverloads
|
||||
# 45| 3: [TypeAccess] int
|
||||
#-----| 4: (Parameters)
|
||||
# 45| 0: [Parameter] <this>
|
||||
@@ -170,6 +172,9 @@ test.kt:
|
||||
# 1| 5: [IntegerLiteral] 23
|
||||
# 1| 6: [NullLiteral] null
|
||||
# 6| 4: [Method] testStaticFunction
|
||||
#-----| 1: (Annotations)
|
||||
# 5| 1: [Annotation] JvmOverloads
|
||||
# 5| 2: [Annotation] JvmStatic
|
||||
# 6| 3: [TypeAccess] int
|
||||
#-----| 4: (Parameters)
|
||||
# 6| 0: [Parameter] a
|
||||
@@ -277,6 +282,8 @@ test.kt:
|
||||
# 1| 6: [IntegerLiteral] 23
|
||||
# 1| 7: [NullLiteral] null
|
||||
# 9| 8: [Method] testMemberFunction
|
||||
#-----| 1: (Annotations)
|
||||
# 8| 1: [Annotation] JvmOverloads
|
||||
# 9| 3: [TypeAccess] int
|
||||
#-----| 4: (Parameters)
|
||||
# 9| 0: [Parameter] a
|
||||
@@ -394,6 +401,8 @@ test.kt:
|
||||
# 1| 7: [IntegerLiteral] 23
|
||||
# 1| 8: [NullLiteral] null
|
||||
# 12| 12: [ExtensionMethod] testMemberExtensionFunction
|
||||
#-----| 1: (Annotations)
|
||||
# 11| 1: [Annotation] JvmOverloads
|
||||
# 12| 3: [TypeAccess] int
|
||||
#-----| 4: (Parameters)
|
||||
# 12| 0: [Parameter] <this>
|
||||
@@ -501,6 +510,8 @@ test.kt:
|
||||
# 1| 5: [IntegerLiteral] 23
|
||||
# 1| 6: [NullLiteral] null
|
||||
# 16| 3: [Constructor] Test2
|
||||
#-----| 1: (Annotations)
|
||||
# 16| 1: [Annotation] JvmOverloads
|
||||
#-----| 4: (Parameters)
|
||||
# 16| 0: [Parameter] a
|
||||
# 16| 0: [TypeAccess] int
|
||||
@@ -609,6 +620,8 @@ test.kt:
|
||||
# 1| 6: [IntegerLiteral] 23
|
||||
# 1| 7: [NullLiteral] null
|
||||
# 21| 4: [Method] testCompanionFunction
|
||||
#-----| 1: (Annotations)
|
||||
# 20| 1: [Annotation] JvmOverloads
|
||||
# 21| 3: [TypeAccess] int
|
||||
#-----| 4: (Parameters)
|
||||
# 21| 0: [Parameter] a
|
||||
@@ -718,6 +731,9 @@ test.kt:
|
||||
# 1| 6: [IntegerLiteral] 23
|
||||
# 1| 7: [NullLiteral] null
|
||||
# 24| 8: [Method] testStaticCompanionFunction
|
||||
#-----| 1: (Annotations)
|
||||
# 23| 1: [Annotation] JvmOverloads
|
||||
# 23| 2: [Annotation] JvmStatic
|
||||
# 24| 3: [TypeAccess] int
|
||||
#-----| 4: (Parameters)
|
||||
# 24| 0: [Parameter] a
|
||||
@@ -883,6 +899,8 @@ test.kt:
|
||||
# 1| 4: [IntegerLiteral] 11
|
||||
# 1| 5: [NullLiteral] null
|
||||
# 30| 3: [Constructor] GenericTest
|
||||
#-----| 1: (Annotations)
|
||||
# 30| 1: [Annotation] JvmOverloads
|
||||
#-----| 4: (Parameters)
|
||||
# 30| 0: [Parameter] a
|
||||
# 30| 0: [TypeAccess] int
|
||||
@@ -974,6 +992,8 @@ test.kt:
|
||||
# 1| 5: [IntegerLiteral] 11
|
||||
# 1| 6: [NullLiteral] null
|
||||
# 33| 7: [Method] testMemberFunction
|
||||
#-----| 1: (Annotations)
|
||||
# 32| 1: [Annotation] JvmOverloads
|
||||
# 33| 3: [TypeAccess] int
|
||||
#-----| 4: (Parameters)
|
||||
# 33| 0: [Parameter] a
|
||||
|
||||
@@ -157,6 +157,8 @@ test.kt:
|
||||
# 17| 0: [KtInitializerAssignExpr] ...=...
|
||||
# 17| 0: [VarAccess] nonStaticProp
|
||||
# 13| 2: [Method] staticMethod
|
||||
#-----| 1: (Annotations)
|
||||
# 13| 1: [Annotation] JvmStatic
|
||||
# 13| 3: [TypeAccess] String
|
||||
#-----| 4: (Parameters)
|
||||
# 13| 0: [Parameter] s
|
||||
@@ -217,6 +219,8 @@ test.kt:
|
||||
# 17| -1: [ThisAccess] this
|
||||
# 17| 1: [VarAccess] <set-?>
|
||||
# 20| 10: [Method] getPropWithStaticGetter
|
||||
#-----| 1: (Annotations)
|
||||
# 20| 1: [Annotation] JvmStatic
|
||||
# 20| 3: [TypeAccess] String
|
||||
# 20| 5: [BlockStmt] { ... }
|
||||
# 20| 0: [ReturnStmt] return ...
|
||||
@@ -239,6 +243,8 @@ test.kt:
|
||||
# 24| 0: [MethodAccess] getPropWithStaticGetter(...)
|
||||
# 24| -1: [ThisAccess] this
|
||||
# 25| 13: [Method] setPropWithStaticSetter
|
||||
#-----| 1: (Annotations)
|
||||
# 25| 1: [Annotation] JvmStatic
|
||||
# 25| 3: [TypeAccess] Unit
|
||||
#-----| 4: (Parameters)
|
||||
# 25| 0: [Parameter] s
|
||||
@@ -307,6 +313,8 @@ test.kt:
|
||||
# 37| 0: [KtInitializerAssignExpr] ...=...
|
||||
# 37| 0: [VarAccess] nonStaticProp
|
||||
# 33| 2: [Method] staticMethod
|
||||
#-----| 1: (Annotations)
|
||||
# 33| 1: [Annotation] JvmStatic
|
||||
# 33| 3: [TypeAccess] String
|
||||
#-----| 4: (Parameters)
|
||||
# 33| 0: [Parameter] s
|
||||
@@ -370,6 +378,8 @@ test.kt:
|
||||
# 37| -1: [ThisAccess] this
|
||||
# 37| 1: [VarAccess] <set-?>
|
||||
# 40| 10: [Method] getPropWithStaticGetter
|
||||
#-----| 1: (Annotations)
|
||||
# 40| 1: [Annotation] JvmStatic
|
||||
# 40| 3: [TypeAccess] String
|
||||
# 40| 5: [BlockStmt] { ... }
|
||||
# 40| 0: [ReturnStmt] return ...
|
||||
@@ -393,6 +403,8 @@ test.kt:
|
||||
# 44| 0: [MethodAccess] getPropWithStaticGetter(...)
|
||||
# 44| -1: [TypeAccess] NonCompanion
|
||||
# 45| 13: [Method] setPropWithStaticSetter
|
||||
#-----| 1: (Annotations)
|
||||
# 45| 1: [Annotation] JvmStatic
|
||||
# 45| 3: [TypeAccess] Unit
|
||||
#-----| 4: (Parameters)
|
||||
# 45| 0: [Parameter] s
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import java
|
||||
|
||||
from Literal l
|
||||
where l.getFile().isSourceFile()
|
||||
select l, l.getPrimaryQlClasses()
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import java
|
||||
|
||||
from Expr e
|
||||
where e.getFile().isSourceFile()
|
||||
select e, e.getPrimaryQlClasses()
|
||||
|
||||
@@ -609,6 +609,8 @@ test.kt:
|
||||
# 32| 0: [SuperConstructorInvocationStmt] super(...)
|
||||
# 32| 1: [BlockStmt] { ... }
|
||||
# 34| 2: [Method] f
|
||||
#-----| 1: (Annotations)
|
||||
# 34| 1: [Annotation] JvmStatic
|
||||
# 34| 3: [TypeAccess] Unit
|
||||
#-----| 4: (Parameters)
|
||||
# 34| 0: [Parameter] x
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import java
|
||||
|
||||
from Expr e
|
||||
where e.getFile().isSourceFile()
|
||||
select e, e.getPrimaryQlClasses()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import java
|
||||
|
||||
query predicate varAcc(VarAccess va) { any() }
|
||||
query predicate varAcc(VarAccess va) { va.getFile().isSourceFile() }
|
||||
|
||||
query predicate extensionReceiverAcc(ExtensionReceiverAccess va) { any() }
|
||||
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
utils/model-generator/CaptureNegativeSummaryModels.ql
|
||||
@@ -0,0 +1 @@
|
||||
utils/model-generator/CaptureNeutralModels.ql
|
||||
Reference in New Issue
Block a user