[LL FIR] fix KtFirReferenceShortener collection for the whole file
previously it worked only for separate declarations ^KT-57966 fixed
This commit is contained in:
committed by
Space Team
parent
793cb02c7d
commit
3b85715f0f
+1
-9
@@ -75,7 +75,7 @@ internal class KtFirReferenceShortener(
|
|||||||
callableShortenOption: (KtCallableSymbol) -> ShortenOption
|
callableShortenOption: (KtCallableSymbol) -> ShortenOption
|
||||||
): ShortenCommand {
|
): ShortenCommand {
|
||||||
val declarationToVisit = file.findSmallestDeclarationContainingSelection(selection)
|
val declarationToVisit = file.findSmallestDeclarationContainingSelection(selection)
|
||||||
?: file.withDeclarationsResolvedToBodyResolve()
|
?: file
|
||||||
|
|
||||||
val firDeclaration = declarationToVisit.getOrBuildFir(firResolveSession) as? FirDeclaration ?: return ShortenCommandImpl(
|
val firDeclaration = declarationToVisit.getOrBuildFir(firResolveSession) as? FirDeclaration ?: return ShortenCommandImpl(
|
||||||
file.createSmartPointer(),
|
file.createSmartPointer(),
|
||||||
@@ -108,14 +108,6 @@ internal class KtFirReferenceShortener(
|
|||||||
collector.qualifiersToShorten.map { it.element }.distinct().map { it.createSmartPointer() }
|
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? =
|
private fun KtFile.findSmallestDeclarationContainingSelection(selection: TextRange): KtDeclaration? =
|
||||||
|
|||||||
Reference in New Issue
Block a user