[FE] Add language feature for context receivers

This commit is contained in:
Anastasiya Shadrina
2021-09-16 17:13:13 +07:00
committed by TeamCityServer
parent 369c86ebb0
commit 910660a083
91 changed files with 222 additions and 3 deletions
@@ -333,6 +333,15 @@ fun PsiElement.isExtensionDeclaration(): Boolean {
return callable?.receiverTypeReference != null
}
fun KtElement.isContextualDeclaration(): Boolean {
val contextReceivers = when (this) {
is KtCallableDeclaration -> contextReceivers
is KtClassOrObject -> contextReceivers
else -> emptyList()
}
return contextReceivers.isNotEmpty()
}
fun KtClassOrObject.isObjectLiteral(): Boolean = this is KtObjectDeclaration && isObjectLiteral()
//TODO: strange method, and not only Kotlin specific (also Java)