FIR2IR: Rework DelegatedMemberGenerator

Use scope content instead of manual traversing of declarations
This commit is contained in:
Denis Zharkov
2020-09-24 14:33:49 +03:00
parent e311a60055
commit b241161c35
11 changed files with 687 additions and 548 deletions
@@ -5,6 +5,8 @@
package org.jetbrains.kotlin.fir.scopes
import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol
import org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol
import org.jetbrains.kotlin.name.Name
interface FirContainingNamesAwareScope {
@@ -18,3 +20,27 @@ fun FirScope.getContainingCallableNamesIfPresent(): Set<Name> =
fun FirScope.getContainingClassifierNamesIfPresent(): Set<Name> =
if (this is FirContainingNamesAwareScope) getClassifierNames() else emptySet()
fun <S> S.processAllFunctions(processor: (FirFunctionSymbol<*>) -> Unit) where S : FirScope, S : FirContainingNamesAwareScope {
for (name in getCallableNames()) {
processFunctionsByName(name, processor)
}
}
fun <S> S.processAllProperties(processor: (FirVariableSymbol<*>) -> Unit) where S : FirScope, S : FirContainingNamesAwareScope {
for (name in getCallableNames()) {
processPropertiesByName(name, processor)
}
}
fun <S> S.collectAllFunctions(): Collection<FirFunctionSymbol<*>> where S : FirScope, S : FirContainingNamesAwareScope {
return mutableListOf<FirFunctionSymbol<*>>().apply {
processAllFunctions(this::add)
}
}
fun <S> S.collectAllProperties(): Collection<FirVariableSymbol<*>> where S : FirScope, S : FirContainingNamesAwareScope {
return mutableListOf<FirVariableSymbol<*>>().apply {
processAllProperties(this::add)
}
}