FIR2IR: Rework DelegatedMemberGenerator
Use scope content instead of manual traversing of declarations
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user