Utilize MemberScope.findFirstFunction with name and predicate

This commit is contained in:
Jinseong Jeon
2022-02-11 23:59:02 -08:00
committed by Ilya Kirillov
parent 26e7fc9da3
commit 476e65f934
4 changed files with 6 additions and 10 deletions
@@ -18,6 +18,7 @@ package org.jetbrains.kotlin.resolve.scopes
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.incremental.components.LookupLocation
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.resolve.scopes.MemberScope.Companion.ALL_NAME_FILTER
import org.jetbrains.kotlin.utils.Printer
@@ -66,6 +67,9 @@ fun MemberScope.computeAllNames() = getClassifierNames()?.let { classifierNames
}
}
inline fun MemberScope.findFirstFunction(name: String, predicate: (CallableMemberDescriptor) -> Boolean) =
getContributedFunctions(Name.identifier(name), NoLookupLocation.FROM_BACKEND).first(predicate)
fun Iterable<MemberScope>.flatMapClassifierNamesOrNull(): MutableSet<Name>? =
flatMapToNullable(hashSetOf(), MemberScope::getClassifierNames)