mirror of
https://github.com/github/codeql.git
synced 2026-05-05 13:45:19 +02:00
Kotlin: Handle properties better
This commit is contained in:
@@ -948,7 +948,8 @@ javadocText(
|
||||
|
||||
/** A program element that has a name. */
|
||||
@element = @file | @package | @primitive | @class | @interface | @method | @constructor | @modifier | @param | @exception | @field |
|
||||
@annotation | @boundedtype | @array | @localvar | @expr | @stmt | @import | @fielddecl | @kt_type | @kt_type_alias;
|
||||
@annotation | @boundedtype | @array | @localvar | @expr | @stmt | @import | @fielddecl | @kt_type | @kt_type_alias |
|
||||
@kt_property;
|
||||
|
||||
@modifiable = @member_modifiable| @param | @localvar ;
|
||||
|
||||
@@ -960,7 +961,7 @@ javadocText(
|
||||
@locatable = @file | @class | @interface | @fielddecl | @field | @constructor | @method | @param | @exception
|
||||
| @boundedtype | @typebound | @array | @primitive
|
||||
| @import | @stmt | @expr | @whenbranch | @localvar | @javadoc | @javadocTag | @javadocText
|
||||
| @xmllocatable | @ktcomment | @kt_type_alias;
|
||||
| @xmllocatable | @ktcomment | @kt_type_alias | @kt_property;
|
||||
|
||||
@top = @element | @locatable | @folder;
|
||||
|
||||
@@ -1108,3 +1109,23 @@ ktExtensionFunctions(
|
||||
int typeid: @type ref,
|
||||
int kttypeid: @kt_type ref
|
||||
)
|
||||
|
||||
ktProperties(
|
||||
unique int id: @kt_property,
|
||||
string nodeName: string ref
|
||||
)
|
||||
|
||||
ktPropertyGetters(
|
||||
unique int id: @kt_property ref,
|
||||
int getter: @method ref
|
||||
)
|
||||
|
||||
ktPropertySetters(
|
||||
unique int id: @kt_property ref,
|
||||
int setter: @method ref
|
||||
)
|
||||
|
||||
ktPropertyBackingFields(
|
||||
unique int id: @kt_property ref,
|
||||
int backingField: @field ref
|
||||
)
|
||||
|
||||
@@ -45,6 +45,8 @@ predicate hasName(Element e, string name) {
|
||||
modifiers(e, name)
|
||||
or
|
||||
kt_type_alias(e, name, _)
|
||||
or
|
||||
ktProperties(e, name)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -686,6 +686,20 @@ class InstanceField extends Field {
|
||||
InstanceField() { not this.isStatic() }
|
||||
}
|
||||
|
||||
/** A Kotlin property. */
|
||||
class Property extends Element, @kt_property {
|
||||
/** Gets the getter method for this property, if any. */
|
||||
Method getGetter() { ktPropertyGetters(this, result) }
|
||||
|
||||
/** Gets the setter method for this property, if any. */
|
||||
Method getSetter() { ktPropertySetters(this, result) }
|
||||
|
||||
/** Gets the backing field for this property, if any. */
|
||||
Field getBackingField() { ktPropertyBackingFields(this, result) }
|
||||
|
||||
override string getAPrimaryQlClass() { result = "Property" }
|
||||
}
|
||||
|
||||
/** A Kotlin extension function. */
|
||||
class ExtensionMethod extends Method {
|
||||
Type extendedType;
|
||||
|
||||
Reference in New Issue
Block a user