Kotlin: Towards KotlinType support

This commit is contained in:
Ian Lynagh
2021-10-14 13:32:43 +01:00
parent ca96d55476
commit 1bce9a131a
5 changed files with 211 additions and 68 deletions

View File

@@ -314,6 +314,18 @@ classes(
int sourceid: @class ref
);
kt_nullable_types(
unique int id: @kt_nullable_type,
int classid: @classorinterface ref
)
kt_notnull_types(
unique int id: @kt_notnull_type,
int classid: @classorinterface ref
)
@kt_type = @kt_nullable_type | @kt_notnull_type
isRecord(
unique int id: @class ref
);
@@ -906,7 +918,7 @@ javadocText(
@type = @primitive | @reftype;
@callable = @method | @constructor;
@element = @file | @package | @primitive | @class | @interface | @method | @constructor | @modifier | @param | @exception | @field |
@annotation | @boundedtype | @array | @localvar | @expr | @stmt | @import | @fielddecl;
@annotation | @boundedtype | @array | @localvar | @expr | @stmt | @import | @fielddecl | @kt_type;
@modifiable = @member_modifiable| @param | @localvar ;

View File

@@ -20,6 +20,7 @@ import semmle.code.java.Javadoc
import semmle.code.java.JDK
import semmle.code.java.JDKAnnotations
import semmle.code.java.JMX
import semmle.code.java.KotlinType
import semmle.code.java.Member
import semmle.code.java.Modifier
import semmle.code.java.Modules

View File

@@ -0,0 +1,27 @@
/**
* Provides classes and predicates for working with Kotlin types.
*/
import java
class KotlinType extends Element, @kt_type {
}
class KotlinNullableType extends KotlinType, @kt_nullable_type {
override string toString() {
exists(ClassOrInterface ci |
kt_nullable_types(this, ci) and
result = "Kotlin nullable " + ci.toString())
}
override string getAPrimaryQlClass() { result = "KotlinNullableType" }
}
class KotlinNotnullType extends KotlinType, @kt_notnull_type {
override string toString() {
exists(ClassOrInterface ci |
kt_notnull_types(this, ci) and
result = "Kotlin not-null " + ci.toString())
}
override string getAPrimaryQlClass() { result = "KotlinNotnullType" }
}