[LL FIR] fix KtFirReferenceShortener collection for the whole file

previously it worked only for separate declarations

^KT-57966 fixed
This commit is contained in:
Ilya Kirillov
2023-04-26 18:07:32 +02:00
committed by Space Team
parent 793cb02c7d
commit 3b85715f0f
@@ -75,7 +75,7 @@ internal class KtFirReferenceShortener(
callableShortenOption: (KtCallableSymbol) -> ShortenOption
): ShortenCommand {
val declarationToVisit = file.findSmallestDeclarationContainingSelection(selection)
?: file.withDeclarationsResolvedToBodyResolve()
?: file
val firDeclaration = declarationToVisit.getOrBuildFir(firResolveSession) as? FirDeclaration ?: return ShortenCommandImpl(
file.createSmartPointer(),
@@ -108,14 +108,6 @@ internal class KtFirReferenceShortener(
collector.qualifiersToShorten.map { it.element }.distinct().map { it.createSmartPointer() }
)
}
private fun KtFile.withDeclarationsResolvedToBodyResolve(): KtFile {
for (declaration in declarations) {
declaration.getOrBuildFir(firResolveSession) // temporary hack, resolves declaration to BODY_RESOLVE stage
}
return this
}
}
private fun KtFile.findSmallestDeclarationContainingSelection(selection: TextRange): KtDeclaration? =