Kotlin: Support apply

This commit is contained in:
Tony Torralba
2023-07-10 16:14:37 +02:00
parent 3c3b53001f
commit 0f18c0227b
6 changed files with 43 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
/** Provides classes and predicates related to `kotlin`. */
import java
/** A call to Kotlin's `apply` method. */
class KotlinApply extends MethodAccess {
ExtensionMethod m;
KotlinApply() {
this.getMethod() = m and
m.hasQualifiedName("kotlin", "StandardKt", "apply")
}
/** Gets the function block argument of this call. */
LambdaExpr getLambdaArg() {
result = this.getArgument(m.getExtensionReceiverParameterIndex() + 1)
}
/** Gets the receiver argument of this call. */
Argument getReceiver() { result = this.getArgument(m.getExtensionReceiverParameterIndex()) }
}