FIR/UAST: commonize labeled expression
This commit is contained in:
committed by
Ilya Kirillov
parent
6e1b04e4c9
commit
c089b8ed04
+26
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.uast.kotlin
|
||||
|
||||
import org.jetbrains.kotlin.psi.KtLabeledExpression
|
||||
import org.jetbrains.uast.UElement
|
||||
import org.jetbrains.uast.UIdentifier
|
||||
import org.jetbrains.uast.ULabeledExpression
|
||||
|
||||
class KotlinULabeledExpression(
|
||||
override val sourcePsi: KtLabeledExpression,
|
||||
givenParent: UElement?
|
||||
) : KotlinAbstractUExpression(givenParent), ULabeledExpression {
|
||||
override val label: String
|
||||
get() = sourcePsi.getLabelName().orAnonymous("label")
|
||||
|
||||
override val labelIdentifier: UIdentifier?
|
||||
get() = sourcePsi.getTargetLabel()?.let { KotlinUIdentifier(it, this) }
|
||||
|
||||
override val expression by lz {
|
||||
baseResolveProviderService.baseKotlinConverter.convertOrEmpty(sourcePsi.baseExpression, this)
|
||||
}
|
||||
}
|
||||
+3
@@ -17,6 +17,9 @@ import java.util.function.Supplier
|
||||
|
||||
typealias BaseResolveProviderServiceSupplier = Supplier<BaseKotlinUastResolveProviderService>
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
inline fun String?.orAnonymous(kind: String = ""): String = this ?: "<anonymous" + (if (kind.isNotBlank()) " $kind" else "") + ">"
|
||||
|
||||
fun <T> lz(initializer: () -> T) =
|
||||
lazy(LazyThreadSafetyMode.SYNCHRONIZED, initializer)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user