Add ExtensionMethod class

This commit is contained in:
Tamas Vajk
2021-09-23 10:11:28 +02:00
committed by Ian Lynagh
parent 7d8b6bac06
commit 3bfc93daab
5 changed files with 22 additions and 2 deletions

View File

@@ -1059,3 +1059,7 @@ ktBreakContinueTarget(
unique int id: @breakcontinuestmt ref,
int target: @ktloopstmt ref
)
ktExtensionFunctions(
unique int id: @method ref
)

View File

@@ -670,3 +670,13 @@ class Field extends Member, ExprParent, @field, Variable {
class InstanceField extends Field {
InstanceField() { not this.isStatic() }
}
/** A Kotlin extension function. */
class ExtensionMethod extends Method {
ExtensionMethod() { ktExtensionFunctions(this) }
/** Gets the type being extended by this method. */
Type getExtendedType() { result = getParameter(-1).getType() }
override string getAPrimaryQlClass() { result = "ExtensionMethod" }
}

View File

@@ -1,3 +1,4 @@
methods
| methods2.kt:4:1:5:1 | fooBarTopLevelMethod |
| methods2.kt:7:1:10:1 | <init> |
| methods2.kt:7:1:10:1 | equals |
@@ -17,3 +18,6 @@
| methods.kt:5:1:13:1 | toString |
| methods.kt:6:5:7:5 | classMethod |
| methods.kt:9:5:12:5 | anotherClassMethod |
extensions
| methods3.kt:3:1:3:39 | fooBarTopLevelMethod | file://:0:0:0:0 | int |
| methods3.kt:6:5:6:43 | fooBarTopLevelMethod | file://:0:0:0:0 | int |

View File

@@ -1,5 +1,5 @@
import java
from Method m
select m
query predicate methods(Method m) { any() }
query predicate extensions(ExtensionMethod m, Type t) { m.getExtendedType() = t }