[LL API] Preserve the original 'FirCodeFragment' after in-body change

This commit is contained in:
Yan Zhulanow
2023-08-04 02:22:22 +09:00
committed by Space Team
parent 27a15cd76d
commit 75868d5f52
@@ -147,26 +147,8 @@ internal class ReanalyzableCodeFragmentStructureElement(
override val timestamp = psi.modificationStamp
override fun reanalyze(): ReanalyzableStructureElement<KtCodeFragment, FirCodeFragmentSymbol> {
val originalCodeFragment = firSymbol.fir
val originalDesignation = originalCodeFragment.collectDesignation()
firFile.transformDeclarations(object : FirTransformer<Nothing?>() {
override fun <E : FirElement> transformElement(element: E, data: Nothing?): E = element
override fun transformCodeFragment(codeFragment: FirCodeFragment, data: Nothing?): FirCodeFragment {
return RawFirNonLocalDeclarationBuilder.build(
session = originalCodeFragment.moduleData.session,
scopeProvider = originalCodeFragment.moduleData.session.kotlinScopeProvider,
designation = originalDesignation,
rootNonLocalDeclaration = psi,
) as FirCodeFragment
}
}, null)
val newCodeFragment = firFile.codeFragment
newCodeFragment.lazyResolveToPhase(FirResolvePhase.BODY_RESOLVE)
return ReanalyzableCodeFragmentStructureElement(firFile, psi, newCodeFragment.symbol, moduleComponents)
firSymbol.lazyResolveToPhase(FirResolvePhase.BODY_RESOLVE)
return ReanalyzableCodeFragmentStructureElement(firFile, psi, firSymbol, moduleComponents)
}
}