Adapt changes in IDE after moving SAM adapters to synthetic scope

The main change is that now to get static sam adapters one should do it using synthetic scopes and static scope of container
This commit is contained in:
Mikhail Zarechenskiy
2017-05-02 15:03:17 +03:00
parent 8e233162ed
commit 429f0e4f68
8 changed files with 66 additions and 16 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2015 JetBrains s.r.o.
* Copyright 2010-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,6 +22,7 @@ import org.jetbrains.kotlin.descriptors.CallableDescriptor
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.ClassKind
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.idea.codeInsight.collectSyntheticStaticMembers
import org.jetbrains.kotlin.idea.core.KotlinIndicesHelper
import org.jetbrains.kotlin.idea.core.targetDescriptors
import org.jetbrains.kotlin.idea.resolve.ResolutionFacade
@@ -76,9 +77,14 @@ class StaticMembersCompletion(
.toSet()
val result = ArrayList<DeclarationDescriptor>()
val kindFilter = DescriptorKindFilter.CALLABLES exclude DescriptorKindExclude.Extensions
val nameFilter = prefixMatcher.asNameFilter()
for (container in containers) {
val memberScope = if (container.kind == ClassKind.OBJECT) container.unsubstitutedMemberScope else container.staticScope
val members = memberScope.getDescriptorsFiltered(DescriptorKindFilter.CALLABLES exclude DescriptorKindExclude.Extensions, prefixMatcher.asNameFilter())
val members =
memberScope.getDescriptorsFiltered(kindFilter, nameFilter) +
memberScope.collectSyntheticStaticMembers(resolutionFacade, kindFilter, nameFilter)
members.filterTo(result) { it is CallableDescriptor && it !in alreadyAdded }
}
return result