[FE] Support context receivers on classes
This commit is contained in:
committed by
TeamCityServer
parent
c34fe8d547
commit
f4ddf66ac4
@@ -25,6 +25,7 @@ import com.intellij.psi.impl.CheckUtil
|
||||
import com.intellij.psi.stubs.IStubElementType
|
||||
import com.intellij.psi.tree.TokenSet
|
||||
import com.intellij.psi.util.PsiTreeUtil
|
||||
import org.jetbrains.kotlin.KtNodeTypes
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
@@ -186,6 +187,23 @@ abstract class KtClassOrObject :
|
||||
parts.reverse()
|
||||
return parts.joinToString(separator = ".")
|
||||
}
|
||||
|
||||
override fun getContextReceiverTypeReferences(): List<KtTypeReference> {
|
||||
val stub = stub
|
||||
if (stub != null) {
|
||||
return getStubOrPsiChildrenAsList(KtStubElementTypes.TYPE_REFERENCE)
|
||||
}
|
||||
var node = node.firstChildNode
|
||||
while (node != null) {
|
||||
val tt = node.elementType
|
||||
if (tt === KtNodeTypes.CONTEXT_RECEIVER) {
|
||||
val contextReceiver = node.psi as KtContextReceiver
|
||||
return contextReceiver.typeReferences()
|
||||
}
|
||||
node = node.treeNext
|
||||
}
|
||||
return emptyList()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -58,6 +58,10 @@ public interface KtPureClassOrObject extends KtPureElement, KtDeclarationContain
|
||||
@ReadOnly
|
||||
List<KtSecondaryConstructor> getSecondaryConstructors();
|
||||
|
||||
@NotNull
|
||||
@ReadOnly
|
||||
List<KtTypeReference> getContextReceiverTypeReferences();
|
||||
|
||||
@Nullable
|
||||
KtClassBody getBody();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user