RawFirBuilder refactoring

Second step for KT-52615
Get rid of PsiHandlingMode
Get rid of source in FirLazyBlock
Refactor lazy creation

Merge-request: KT-MR-7753
Merged-by: Egor Kulikov <Egor.Kulikov@jetbrains.com>
This commit is contained in:
Egor Kulikov
2022-11-22 14:43:53 +00:00
committed by Space Team
parent 27949bccf6
commit 067036c162
18 changed files with 96 additions and 126 deletions
@@ -25,33 +25,7 @@ import org.jetbrains.kotlin.fir.visitors.*
* DO NOT MODIFY IT MANUALLY
*/
@FirBuilderDsl
class FirLazyBlockBuilder : FirAnnotationContainerBuilder, FirExpressionBuilder {
override var source: KtSourceElement? = null
@OptIn(FirImplementationDetail::class)
override fun build(): FirBlock {
return FirLazyBlock(
source,
)
}
@Deprecated("Modification of 'annotations' has no impact for FirLazyBlockBuilder", level = DeprecationLevel.HIDDEN)
override val annotations: MutableList<FirAnnotation> = mutableListOf()
@Deprecated("Modification of 'typeRef' has no impact for FirLazyBlockBuilder", level = DeprecationLevel.HIDDEN)
override var typeRef: FirTypeRef
get() = throw IllegalStateException()
set(_) {
throw IllegalStateException()
}
}
@OptIn(ExperimentalContracts::class)
inline fun buildLazyBlock(init: FirLazyBlockBuilder.() -> Unit = {}): FirBlock {
contract {
callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE)
}
return FirLazyBlockBuilder().apply(init).build()
@OptIn(FirImplementationDetail::class)
fun buildLazyBlock(): FirBlock {
return FirLazyBlock()
}
@@ -20,9 +20,8 @@ import org.jetbrains.kotlin.fir.visitors.*
* DO NOT MODIFY IT MANUALLY
*/
class FirLazyBlock @FirImplementationDetail constructor(
override val source: KtSourceElement?,
) : FirBlock() {
class FirLazyBlock : FirBlock() {
override val source: KtSourceElement? get() = error("FirLazyBlock should be calculated before accessing")
override val annotations: List<FirAnnotation> get() = error("FirLazyBlock should be calculated before accessing")
override val statements: List<FirStatement> get() = error("FirLazyBlock should be calculated before accessing")
override val typeRef: FirTypeRef get() = error("FirLazyBlock should be calculated before accessing")
@@ -142,6 +142,10 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator()
impl(block, "FirLazyBlock") {
val error = """error("FirLazyBlock should be calculated before accessing")"""
default("source") {
value = error
withGetter = true
}
default("statements") {
value = error
withGetter = true