[LL API] Preserve the original 'FirCodeFragment' after in-body change
This commit is contained in:
+2
-20
@@ -147,26 +147,8 @@ internal class ReanalyzableCodeFragmentStructureElement(
|
|||||||
override val timestamp = psi.modificationStamp
|
override val timestamp = psi.modificationStamp
|
||||||
|
|
||||||
override fun reanalyze(): ReanalyzableStructureElement<KtCodeFragment, FirCodeFragmentSymbol> {
|
override fun reanalyze(): ReanalyzableStructureElement<KtCodeFragment, FirCodeFragmentSymbol> {
|
||||||
val originalCodeFragment = firSymbol.fir
|
firSymbol.lazyResolveToPhase(FirResolvePhase.BODY_RESOLVE)
|
||||||
val originalDesignation = originalCodeFragment.collectDesignation()
|
return ReanalyzableCodeFragmentStructureElement(firFile, psi, firSymbol, moduleComponents)
|
||||||
|
|
||||||
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)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user