[FIR] Create 'FirCodeFragment' with a lazy block if requested

This commit is contained in:
Yan Zhulanow
2023-07-13 18:20:59 +09:00
committed by Space Team
parent 6896684d36
commit 4b43e72440
@@ -1197,13 +1197,15 @@ open class PsiRawFirBuilder(
moduleData = baseModuleData moduleData = baseModuleData
origin = FirDeclarationOrigin.Source origin = FirDeclarationOrigin.Source
symbol = FirCodeFragmentSymbol() symbol = FirCodeFragmentSymbol()
block = when (file) { block = buildOrLazyBlock {
when (file) {
is KtExpressionCodeFragment -> file.getContentElement()?.toFirBlock() ?: buildEmptyExpressionBlock() is KtExpressionCodeFragment -> file.getContentElement()?.toFirBlock() ?: buildEmptyExpressionBlock()
is KtBlockCodeFragment -> configureBlockWithoutBuilding(file.getContentElement()).build() is KtBlockCodeFragment -> configureBlockWithoutBuilding(file.getContentElement()).build()
else -> error("Unexpected code fragment type: ${file::class}") else -> error("Unexpected code fragment type: ${file::class}")
} }
} }
} }
}
// TODO: if no original FirScript is passed here, the invalid script could be constructed, consider throwing an error // TODO: if no original FirScript is passed here, the invalid script could be constructed, consider throwing an error
override fun visitScript(script: KtScript, data: FirElement?): FirElement { override fun visitScript(script: KtScript, data: FirElement?): FirElement {