Minor: reformat ReferenceVariantsHelper.kt

This commit is contained in:
Dmitry Savvinov
2019-05-29 14:00:23 +03:00
parent 00f8f09274
commit eda975d317
@@ -51,36 +51,37 @@ import org.jetbrains.kotlin.types.typeUtil.isUnit
import java.util.* import java.util.*
class ReferenceVariantsHelper( class ReferenceVariantsHelper(
private val bindingContext: BindingContext, private val bindingContext: BindingContext,
private val resolutionFacade: ResolutionFacade, private val resolutionFacade: ResolutionFacade,
private val moduleDescriptor: ModuleDescriptor, private val moduleDescriptor: ModuleDescriptor,
private val visibilityFilter: (DeclarationDescriptor) -> Boolean, private val visibilityFilter: (DeclarationDescriptor) -> Boolean,
private val notProperties: Set<FqNameUnsafe> = setOf() private val notProperties: Set<FqNameUnsafe> = setOf()
) { ) {
fun getReferenceVariants( fun getReferenceVariants(
expression: KtSimpleNameExpression, expression: KtSimpleNameExpression,
kindFilter: DescriptorKindFilter, kindFilter: DescriptorKindFilter,
nameFilter: (Name) -> Boolean, nameFilter: (Name) -> Boolean,
filterOutJavaGettersAndSetters: Boolean = true, filterOutJavaGettersAndSetters: Boolean = true,
filterOutShadowed: Boolean = true, filterOutShadowed: Boolean = true,
excludeNonInitializedVariable: Boolean = true, excludeNonInitializedVariable: Boolean = true,
useReceiverType: KotlinType? = null useReceiverType: KotlinType? = null
): Collection<DeclarationDescriptor> ): Collection<DeclarationDescriptor> = getReferenceVariants(
= getReferenceVariants(expression, CallTypeAndReceiver.detect(expression), expression, CallTypeAndReceiver.detect(expression),
kindFilter, nameFilter, filterOutJavaGettersAndSetters, filterOutShadowed, excludeNonInitializedVariable, useReceiverType) kindFilter, nameFilter, filterOutJavaGettersAndSetters, filterOutShadowed, excludeNonInitializedVariable, useReceiverType
)
fun getReferenceVariants( fun getReferenceVariants(
contextElement: PsiElement, contextElement: PsiElement,
callTypeAndReceiver: CallTypeAndReceiver<*, *>, callTypeAndReceiver: CallTypeAndReceiver<*, *>,
kindFilter: DescriptorKindFilter, kindFilter: DescriptorKindFilter,
nameFilter: (Name) -> Boolean, nameFilter: (Name) -> Boolean,
filterOutJavaGettersAndSetters: Boolean = true, filterOutJavaGettersAndSetters: Boolean = true,
filterOutShadowed: Boolean = true, filterOutShadowed: Boolean = true,
excludeNonInitializedVariable: Boolean = true, excludeNonInitializedVariable: Boolean = true,
useReceiverType: KotlinType? = null useReceiverType: KotlinType? = null
): Collection<DeclarationDescriptor> { ): Collection<DeclarationDescriptor> {
var variants: Collection<DeclarationDescriptor> var variants: Collection<DeclarationDescriptor> =
= getReferenceVariantsNoVisibilityFilter(contextElement, kindFilter, nameFilter, callTypeAndReceiver, useReceiverType) getReferenceVariantsNoVisibilityFilter(contextElement, kindFilter, nameFilter, callTypeAndReceiver, useReceiverType)
.filter { !resolutionFacade.frontendService<DeprecationResolver>().isHiddenInResolution(it) && visibilityFilter(it) } .filter { !resolutionFacade.frontendService<DeprecationResolver>().isHiddenInResolution(it) && visibilityFilter(it) }
if (filterOutShadowed) { if (filterOutShadowed) {
@@ -100,7 +101,7 @@ class ReferenceVariantsHelper(
return variants return variants
} }
fun <TDescriptor: DeclarationDescriptor> filterOutJavaGettersAndSetters(variants: Collection<TDescriptor>): Collection<TDescriptor> { fun <TDescriptor : DeclarationDescriptor> filterOutJavaGettersAndSetters(variants: Collection<TDescriptor>): Collection<TDescriptor> {
val accessorMethodsToRemove = HashSet<FunctionDescriptor>() val accessorMethodsToRemove = HashSet<FunctionDescriptor>()
val filteredVariants = variants.filter { it !is SyntheticJavaPropertyDescriptor || !it.suppressedByNotPropertyList(notProperties) } val filteredVariants = variants.filter { it !is SyntheticJavaPropertyDescriptor || !it.suppressedByNotPropertyList(notProperties) }
@@ -119,7 +120,10 @@ class ReferenceVariantsHelper(
} }
// filters out variable inside its initializer // filters out variable inside its initializer
fun excludeNonInitializedVariable(variants: Collection<DeclarationDescriptor>, contextElement: PsiElement): Collection<DeclarationDescriptor> { fun excludeNonInitializedVariable(
variants: Collection<DeclarationDescriptor>,
contextElement: PsiElement
): Collection<DeclarationDescriptor> {
for (element in contextElement.parentsWithSelf) { for (element in contextElement.parentsWithSelf) {
val parent = element.parent val parent = element.parent
if (parent is KtVariableDeclaration && element == parent.initializer) { if (parent is KtVariableDeclaration && element == parent.initializer) {
@@ -131,11 +135,11 @@ class ReferenceVariantsHelper(
} }
private fun getReferenceVariantsNoVisibilityFilter( private fun getReferenceVariantsNoVisibilityFilter(
contextElement: PsiElement, contextElement: PsiElement,
kindFilter: DescriptorKindFilter, kindFilter: DescriptorKindFilter,
nameFilter: (Name) -> Boolean, nameFilter: (Name) -> Boolean,
callTypeAndReceiver: CallTypeAndReceiver<*, *>, callTypeAndReceiver: CallTypeAndReceiver<*, *>,
useReceiverType: KotlinType? useReceiverType: KotlinType?
): Collection<DeclarationDescriptor> { ): Collection<DeclarationDescriptor> {
val callType = callTypeAndReceiver.callType val callType = callTypeAndReceiver.callType
@@ -205,20 +209,30 @@ class ReferenceVariantsHelper(
val explicitReceiverTypes = if (useReceiverType != null) { val explicitReceiverTypes = if (useReceiverType != null) {
listOf(useReceiverType) listOf(useReceiverType)
} } else {
else { callTypeAndReceiver.receiverTypes(
callTypeAndReceiver.receiverTypes(bindingContext, contextElement, moduleDescriptor, resolutionFacade, stableSmartCastsOnly = false)!! bindingContext,
contextElement,
moduleDescriptor,
resolutionFacade,
stableSmartCastsOnly = false
)!!
} }
descriptors.processAll(implicitReceiverTypes, explicitReceiverTypes, resolutionScope, callType, kindFilter, nameFilter) descriptors.processAll(implicitReceiverTypes, explicitReceiverTypes, resolutionScope, callType, kindFilter, nameFilter)
} } else {
else {
assert(useReceiverType == null) { "'useReceiverType' parameter is not supported for implicit receiver" } assert(useReceiverType == null) { "'useReceiverType' parameter is not supported for implicit receiver" }
descriptors.processAll(implicitReceiverTypes, implicitReceiverTypes, resolutionScope, callType, kindFilter, nameFilter) descriptors.processAll(implicitReceiverTypes, implicitReceiverTypes, resolutionScope, callType, kindFilter, nameFilter)
// add non-instance members // add non-instance members
descriptors.addAll(resolutionScope.collectDescriptorsFiltered(filterWithoutExtensions, nameFilter, changeNamesForAliased = true)) descriptors.addAll(
resolutionScope.collectDescriptorsFiltered(
filterWithoutExtensions,
nameFilter,
changeNamesForAliased = true
)
)
descriptors.addAll(resolutionScope.collectAllFromMeAndParent { scope -> descriptors.addAll(resolutionScope.collectAllFromMeAndParent { scope ->
scope.collectSyntheticStaticMembersAndConstructors(resolutionFacade, kindFilter, nameFilter) scope.collectSyntheticStaticMembersAndConstructors(resolutionFacade, kindFilter, nameFilter)
}) })
@@ -226,7 +240,9 @@ class ReferenceVariantsHelper(
if (callType == CallType.SUPER_MEMBERS) { // we need to unwrap fake overrides in case of "super." because ShadowedDeclarationsFilter does not work correctly if (callType == CallType.SUPER_MEMBERS) { // we need to unwrap fake overrides in case of "super." because ShadowedDeclarationsFilter does not work correctly
return descriptors.flatMapTo(LinkedHashSet<DeclarationDescriptor>()) { return descriptors.flatMapTo(LinkedHashSet<DeclarationDescriptor>()) {
if (it is CallableMemberDescriptor && it.kind == CallableMemberDescriptor.Kind.FAKE_OVERRIDE) it.overriddenDescriptors else listOf(it) if (it is CallableMemberDescriptor && it.kind == CallableMemberDescriptor.Kind.FAKE_OVERRIDE) it.overriddenDescriptors else listOf(
it
)
} }
} }
@@ -234,27 +250,26 @@ class ReferenceVariantsHelper(
} }
private fun getVariantsForUserType( private fun getVariantsForUserType(
receiverExpression: KtExpression?, receiverExpression: KtExpression?,
contextElement: PsiElement, contextElement: PsiElement,
kindFilter: DescriptorKindFilter, kindFilter: DescriptorKindFilter,
nameFilter: (Name) -> Boolean nameFilter: (Name) -> Boolean
): Collection<DeclarationDescriptor> { ): Collection<DeclarationDescriptor> {
if (receiverExpression != null) { if (receiverExpression != null) {
val qualifier = bindingContext[BindingContext.QUALIFIER, receiverExpression] ?: return emptyList() val qualifier = bindingContext[BindingContext.QUALIFIER, receiverExpression] ?: return emptyList()
return qualifier.staticScope.collectStaticMembers(resolutionFacade, kindFilter, nameFilter) return qualifier.staticScope.collectStaticMembers(resolutionFacade, kindFilter, nameFilter)
} } else {
else {
val scope = contextElement.getResolutionScope(bindingContext, resolutionFacade) val scope = contextElement.getResolutionScope(bindingContext, resolutionFacade)
return scope.collectDescriptorsFiltered(kindFilter, nameFilter, changeNamesForAliased = true) return scope.collectDescriptorsFiltered(kindFilter, nameFilter, changeNamesForAliased = true)
} }
} }
private fun getVariantsForCallableReference( private fun getVariantsForCallableReference(
callTypeAndReceiver: CallTypeAndReceiver.CALLABLE_REFERENCE, callTypeAndReceiver: CallTypeAndReceiver.CALLABLE_REFERENCE,
contextElement: PsiElement, contextElement: PsiElement,
useReceiverType: KotlinType?, useReceiverType: KotlinType?,
kindFilter: DescriptorKindFilter, kindFilter: DescriptorKindFilter,
nameFilter: (Name) -> Boolean nameFilter: (Name) -> Boolean
): Collection<DeclarationDescriptor> { ): Collection<DeclarationDescriptor> {
val descriptors = LinkedHashSet<DeclarationDescriptor>() val descriptors = LinkedHashSet<DeclarationDescriptor>()
@@ -266,59 +281,69 @@ class ReferenceVariantsHelper(
val explicitReceiverTypes = if (useReceiverType != null) { val explicitReceiverTypes = if (useReceiverType != null) {
listOf(useReceiverType) listOf(useReceiverType)
} } else {
else { callTypeAndReceiver.receiverTypes(
callTypeAndReceiver.receiverTypes(bindingContext, contextElement, moduleDescriptor, resolutionFacade, stableSmartCastsOnly = false)!! bindingContext,
contextElement,
moduleDescriptor,
resolutionFacade,
stableSmartCastsOnly = false
)!!
} }
val constructorFilter = { descriptor: ClassDescriptor -> if (isStatic) true else descriptor.isInner } val constructorFilter = { descriptor: ClassDescriptor -> if (isStatic) true else descriptor.isInner }
descriptors.addNonExtensionMembers(explicitReceiverTypes, kindFilter, nameFilter, constructorFilter) descriptors.addNonExtensionMembers(explicitReceiverTypes, kindFilter, nameFilter, constructorFilter)
descriptors.addScopeAndSyntheticExtensions(resolutionScope, explicitReceiverTypes, CallType.CALLABLE_REFERENCE, kindFilter, nameFilter) descriptors.addScopeAndSyntheticExtensions(
resolutionScope,
explicitReceiverTypes,
CallType.CALLABLE_REFERENCE,
kindFilter,
nameFilter
)
if (isStatic) { if (isStatic) {
explicitReceiverTypes explicitReceiverTypes
.mapNotNull { (it.constructor.declarationDescriptor as? ClassDescriptor)?.staticScope } .mapNotNull { (it.constructor.declarationDescriptor as? ClassDescriptor)?.staticScope }
.flatMapTo(descriptors) { it.collectStaticMembers(resolutionFacade, kindFilter, nameFilter) } .flatMapTo(descriptors) { it.collectStaticMembers(resolutionFacade, kindFilter, nameFilter) }
} }
} } else {
else {
// process non-instance members and class constructors // process non-instance members and class constructors
descriptors.addNonExtensionCallablesAndConstructors( descriptors.addNonExtensionCallablesAndConstructors(
resolutionScope, resolutionScope,
kindFilter, nameFilter, constructorFilter = { !it.isInner }, kindFilter, nameFilter, constructorFilter = { !it.isInner },
classesOnly = false classesOnly = false
) )
} }
return descriptors return descriptors
} }
private fun getVariantsForImportOrPackageDirective( private fun getVariantsForImportOrPackageDirective(
receiverExpression: KtExpression?, receiverExpression: KtExpression?,
kindFilter: DescriptorKindFilter, kindFilter: DescriptorKindFilter,
nameFilter: (Name) -> Boolean nameFilter: (Name) -> Boolean
): Collection<DeclarationDescriptor> { ): Collection<DeclarationDescriptor> {
if (receiverExpression != null) { if (receiverExpression != null) {
val qualifier = bindingContext[BindingContext.QUALIFIER, receiverExpression] ?: return emptyList() val qualifier = bindingContext[BindingContext.QUALIFIER, receiverExpression] ?: return emptyList()
val staticDescriptors = qualifier.staticScope.collectStaticMembers(resolutionFacade, kindFilter, nameFilter) val staticDescriptors = qualifier.staticScope.collectStaticMembers(resolutionFacade, kindFilter, nameFilter)
val objectDescriptor = (qualifier as? ClassQualifier)?.descriptor?.takeIf { it.kind == ClassKind.OBJECT } ?: return staticDescriptors val objectDescriptor =
(qualifier as? ClassQualifier)?.descriptor?.takeIf { it.kind == ClassKind.OBJECT } ?: return staticDescriptors
return staticDescriptors + objectDescriptor.defaultType.memberScope.getDescriptorsFiltered(kindFilter, nameFilter) return staticDescriptors + objectDescriptor.defaultType.memberScope.getDescriptorsFiltered(kindFilter, nameFilter)
} } else {
else {
val rootPackage = resolutionFacade.moduleDescriptor.getPackage(FqName.ROOT) val rootPackage = resolutionFacade.moduleDescriptor.getPackage(FqName.ROOT)
return rootPackage.memberScope.getDescriptorsFiltered(kindFilter, nameFilter) return rootPackage.memberScope.getDescriptorsFiltered(kindFilter, nameFilter)
} }
} }
private fun MutableSet<DeclarationDescriptor>.processAll( private fun MutableSet<DeclarationDescriptor>.processAll(
implicitReceiverTypes: Collection<KotlinType>, implicitReceiverTypes: Collection<KotlinType>,
receiverTypes: Collection<KotlinType>, receiverTypes: Collection<KotlinType>,
resolutionScope: LexicalScope, resolutionScope: LexicalScope,
callType: CallType<*>, callType: CallType<*>,
kindFilter: DescriptorKindFilter, kindFilter: DescriptorKindFilter,
nameFilter: (Name) -> Boolean nameFilter: (Name) -> Boolean
) { ) {
addNonExtensionMembers(receiverTypes, kindFilter, nameFilter, constructorFilter = { it.isInner }) addNonExtensionMembers(receiverTypes, kindFilter, nameFilter, constructorFilter = { it.isInner })
addMemberExtensions(implicitReceiverTypes, receiverTypes, callType, kindFilter, nameFilter) addMemberExtensions(implicitReceiverTypes, receiverTypes, callType, kindFilter, nameFilter)
@@ -326,11 +351,11 @@ class ReferenceVariantsHelper(
} }
private fun MutableSet<DeclarationDescriptor>.addMemberExtensions( private fun MutableSet<DeclarationDescriptor>.addMemberExtensions(
dispatchReceiverTypes: Collection<KotlinType>, dispatchReceiverTypes: Collection<KotlinType>,
extensionReceiverTypes: Collection<KotlinType>, extensionReceiverTypes: Collection<KotlinType>,
callType: CallType<*>, callType: CallType<*>,
kindFilter: DescriptorKindFilter, kindFilter: DescriptorKindFilter,
nameFilter: (Name) -> Boolean nameFilter: (Name) -> Boolean
) { ) {
val memberFilter = kindFilter exclude DescriptorKindExclude.NonExtensions val memberFilter = kindFilter exclude DescriptorKindExclude.NonExtensions
for (dispatchReceiverType in dispatchReceiverTypes) { for (dispatchReceiverType in dispatchReceiverTypes) {
@@ -341,35 +366,36 @@ class ReferenceVariantsHelper(
} }
private fun MutableSet<DeclarationDescriptor>.addNonExtensionMembers( private fun MutableSet<DeclarationDescriptor>.addNonExtensionMembers(
receiverTypes: Collection<KotlinType>, receiverTypes: Collection<KotlinType>,
kindFilter: DescriptorKindFilter, kindFilter: DescriptorKindFilter,
nameFilter: (Name) -> Boolean, nameFilter: (Name) -> Boolean,
constructorFilter: (ClassDescriptor) -> Boolean constructorFilter: (ClassDescriptor) -> Boolean
) { ) {
for (receiverType in receiverTypes) { for (receiverType in receiverTypes) {
addNonExtensionCallablesAndConstructors( addNonExtensionCallablesAndConstructors(
receiverType.memberScope.memberScopeAsImportingScope(), receiverType.memberScope.memberScopeAsImportingScope(),
kindFilter, nameFilter, constructorFilter, kindFilter, nameFilter, constructorFilter,
false false
) )
receiverType.constructor.supertypes.forEach { receiverType.constructor.supertypes.forEach {
addNonExtensionCallablesAndConstructors( addNonExtensionCallablesAndConstructors(
it.memberScope.memberScopeAsImportingScope(), it.memberScope.memberScopeAsImportingScope(),
kindFilter, nameFilter, constructorFilter, kindFilter, nameFilter, constructorFilter,
true true
) )
} }
} }
} }
private fun MutableSet<DeclarationDescriptor>.addNonExtensionCallablesAndConstructors( private fun MutableSet<DeclarationDescriptor>.addNonExtensionCallablesAndConstructors(
scope: HierarchicalScope, scope: HierarchicalScope,
kindFilter: DescriptorKindFilter, kindFilter: DescriptorKindFilter,
nameFilter: (Name) -> Boolean, nameFilter: (Name) -> Boolean,
constructorFilter: (ClassDescriptor) -> Boolean, constructorFilter: (ClassDescriptor) -> Boolean,
classesOnly: Boolean classesOnly: Boolean
) { ) {
var filterToUse = DescriptorKindFilter(kindFilter.kindMask and DescriptorKindFilter.CALLABLES.kindMask).exclude(DescriptorKindExclude.Extensions) var filterToUse =
DescriptorKindFilter(kindFilter.kindMask and DescriptorKindFilter.CALLABLES.kindMask).exclude(DescriptorKindExclude.Extensions)
// should process classes if we need constructors // should process classes if we need constructors
if (filterToUse.acceptsKinds(DescriptorKindFilter.FUNCTIONS_MASK)) { if (filterToUse.acceptsKinds(DescriptorKindFilter.FUNCTIONS_MASK)) {
@@ -381,19 +407,18 @@ class ReferenceVariantsHelper(
if (descriptor.modality == Modality.ABSTRACT || descriptor.modality == Modality.SEALED) continue if (descriptor.modality == Modality.ABSTRACT || descriptor.modality == Modality.SEALED) continue
if (!constructorFilter(descriptor)) continue if (!constructorFilter(descriptor)) continue
descriptor.constructors.filterTo(this) { kindFilter.accepts(it) } descriptor.constructors.filterTo(this) { kindFilter.accepts(it) }
} } else if (!classesOnly && kindFilter.accepts(descriptor)) {
else if (!classesOnly && kindFilter.accepts(descriptor)) {
this.add(descriptor) this.add(descriptor)
} }
} }
} }
private fun MutableSet<DeclarationDescriptor>.addScopeAndSyntheticExtensions( private fun MutableSet<DeclarationDescriptor>.addScopeAndSyntheticExtensions(
scope: LexicalScope, scope: LexicalScope,
receiverTypes: Collection<KotlinType>, receiverTypes: Collection<KotlinType>,
callType: CallType<*>, callType: CallType<*>,
kindFilter: DescriptorKindFilter, kindFilter: DescriptorKindFilter,
nameFilter: (Name) -> Boolean nameFilter: (Name) -> Boolean
) { ) {
if (kindFilter.excludes.contains(DescriptorKindExclude.Extensions)) return if (kindFilter.excludes.contains(DescriptorKindExclude.Extensions)) return
if (receiverTypes.isEmpty()) return if (receiverTypes.isEmpty()) return
@@ -402,14 +427,17 @@ class ReferenceVariantsHelper(
if (kindFilter.accepts(extensionOrSyntheticMember) && nameFilter(extensionOrSyntheticMember.name)) { if (kindFilter.accepts(extensionOrSyntheticMember) && nameFilter(extensionOrSyntheticMember.name)) {
if (extensionOrSyntheticMember.isExtension) { if (extensionOrSyntheticMember.isExtension) {
addAll(extensionOrSyntheticMember.substituteExtensionIfCallable(receiverTypes, callType)) addAll(extensionOrSyntheticMember.substituteExtensionIfCallable(receiverTypes, callType))
} } else {
else {
add(extensionOrSyntheticMember) add(extensionOrSyntheticMember)
} }
} }
} }
for (descriptor in scope.collectDescriptorsFiltered(kindFilter exclude DescriptorKindExclude.NonExtensions, nameFilter, changeNamesForAliased = true)) { for (descriptor in scope.collectDescriptorsFiltered(
kindFilter exclude DescriptorKindExclude.NonExtensions,
nameFilter,
changeNamesForAliased = true
)) {
// todo: sometimes resolution scope here is LazyJavaClassMemberScope. see ea.jetbrains.com/browser/ea_problems/72572 // todo: sometimes resolution scope here is LazyJavaClassMemberScope. see ea.jetbrains.com/browser/ea_problems/72572
process(descriptor as CallableDescriptor) process(descriptor as CallableDescriptor)
} }
@@ -433,19 +461,23 @@ class ReferenceVariantsHelper(
} }
private fun MemberScope.collectStaticMembers( private fun MemberScope.collectStaticMembers(
resolutionFacade: ResolutionFacade, resolutionFacade: ResolutionFacade,
kindFilter: DescriptorKindFilter, kindFilter: DescriptorKindFilter,
nameFilter: (Name) -> Boolean nameFilter: (Name) -> Boolean
): Collection<DeclarationDescriptor> { ): Collection<DeclarationDescriptor> {
return getDescriptorsFiltered(kindFilter, nameFilter) + collectSyntheticStaticMembersAndConstructors(resolutionFacade, kindFilter, nameFilter) return getDescriptorsFiltered(kindFilter, nameFilter) + collectSyntheticStaticMembersAndConstructors(
resolutionFacade,
kindFilter,
nameFilter
)
} }
fun ResolutionScope.collectSyntheticStaticMembersAndConstructors( fun ResolutionScope.collectSyntheticStaticMembersAndConstructors(
resolutionFacade: ResolutionFacade, resolutionFacade: ResolutionFacade,
kindFilter: DescriptorKindFilter, kindFilter: DescriptorKindFilter,
nameFilter: (Name) -> Boolean nameFilter: (Name) -> Boolean
): List<FunctionDescriptor> { ): List<FunctionDescriptor> {
val syntheticScopes = resolutionFacade.getFrontendService(SyntheticScopes::class.java) val syntheticScopes = resolutionFacade.getFrontendService(SyntheticScopes::class.java)
return (syntheticScopes.collectSyntheticStaticFunctions(this) + syntheticScopes.collectSyntheticConstructors(this)) return (syntheticScopes.collectSyntheticStaticFunctions(this) + syntheticScopes.collectSyntheticConstructors(this))
.filter { kindFilter.accepts(it) && nameFilter(it.name) } .filter { kindFilter.accepts(it) && nameFilter(it.name) }
} }