summaryrefslogtreecommitdiff
path: root/plugins/kotlin/uast/uast-kotlin-base/src/org/jetbrains/uast/kotlin/expressions/KotlinSupertypeDelegationUExpression.kt
blob: f5fd256d2a39b686a15aa92589dc7aa7058870d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.

package org.jetbrains.uast.kotlin

import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.psi.KtDelegatedSuperTypeEntry
import org.jetbrains.uast.*
import org.jetbrains.uast.kotlin.kinds.KotlinSpecialExpressionKinds

class KotlinSupertypeDelegationUExpression(
    override val sourcePsi: KtDelegatedSuperTypeEntry,
    givenParent: UElement?
) : KotlinAbstractUExpression(givenParent), UExpressionList {

    override val psi: PsiElement
        get() = sourcePsi

    val typeReference: UTypeReferenceExpression? by lz {
        sourcePsi.typeReference?.let {
            KotlinUTypeReferenceExpression(it, this) {
                baseResolveProviderService.resolveToType(it, this, boxed = false) ?: UastErrorType
            }
        }
    }

    val delegateExpression: UExpression? by lz {
        sourcePsi.delegateExpression?.let { languagePlugin?.convertElement(it, this, UExpression::class.java) as? UExpression }
    }

    override val expressions: List<UExpression>
        get() = listOfNotNull(typeReference, delegateExpression)

    override val kind: UastSpecialExpressionKind
        get() = KotlinSpecialExpressionKinds.SUPER_DELEGATION
}