[Analysis API FIR] refactor, extract createScopesWithKind to a separate function

it will be reused in the following commits

^KT-57966
This commit is contained in:
Ilya Kirillov
2023-05-01 11:38:18 +02:00
committed by Space Team
parent 67041851fc
commit 349e55cb00
@@ -196,11 +196,15 @@ internal class KtFirScopeProvider(
val availableScopes = towerDataElement.getAvailableScopes().flatMap { flattenFirScope(it) }
availableScopes.map { IndexedValue(index, it) }
}
val scopes = firScopes.map { (index, firScope) ->
val ktScopesWithKinds = createScopesWithKind(firScopes)
return KtScopeContext(ktScopesWithKinds, implicitReceivers, token)
}
private fun createScopesWithKind(firScopes: Iterable<IndexedValue<FirScope>>): List<KtScopeWithKind> {
return firScopes.map { (index, firScope) ->
KtScopeWithKind(convertToKtScope(firScope), getScopeKind(firScope, index), token)
}
return KtScopeContext(scopes, implicitReceivers, token)
}
private fun flattenFirScope(firScope: FirScope): List<FirScope> = when (firScope) {